Skip to content

Commit

Permalink
update(I*VirtualObject): Checked on Fields returning classes. Altered…
Browse files Browse the repository at this point in the history
… them to remove interfaces instead.
  • Loading branch information
JaXt0r committed Sep 17, 2024
1 parent 074f7f4 commit 90685cb
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 105 deletions.
6 changes: 3 additions & 3 deletions ZenKit/Vobs/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IContainer : IInteractiveObject
string PickString { get; set; }
string Contents { get; set; }
int ItemCount { get; }
List<Item> Items { get; }
List<IItem> Items { get; }
void AddItem(Item item);
void RemoveItem(int i);
}
Expand Down Expand Up @@ -61,11 +61,11 @@ public string Contents

public int ItemCount => (int)Native.ZkContainer_getItemCount(Handle);

public List<Item> Items
public List<IItem> Items
{
get
{
var items = new List<Item>();
var items = new List<IItem>();

for (var i = 0; i < ItemCount; ++i)
{
Expand Down
10 changes: 5 additions & 5 deletions ZenKit/Vobs/CutsceneCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public interface ICutsceneCamera : IVirtualObject
int PositionCount { get; }
int TargetCount { get; }
int FrameCount { get; }
List<CameraTrajectoryFrame> Frames { get; }
CameraTrajectoryFrame GetFrame(int i);
List<ICameraTrajectoryFrame> Frames { get; }
ICameraTrajectoryFrame GetFrame(int i);
}

public class CutsceneCamera : VirtualObject, ICutsceneCamera
Expand Down Expand Up @@ -279,11 +279,11 @@ public float AutoUntriggerLastDelay
public int TargetCount => Native.ZkCutsceneCamera_getTargetCount(Handle);
public int FrameCount => (int)Native.ZkCutsceneCamera_getFrameCount(Handle);

public List<CameraTrajectoryFrame> Frames
public List<ICameraTrajectoryFrame> Frames
{
get
{
var frames = new List<CameraTrajectoryFrame>();
var frames = new List<ICameraTrajectoryFrame>();
var count = FrameCount;
for (var i = 0; i < count; ++i) frames.Add(GetFrame(i));
return frames;
Expand All @@ -295,7 +295,7 @@ protected override void Delete()
Native.ZkCutsceneCamera_del(Handle);
}

public CameraTrajectoryFrame GetFrame(int i)
public ICameraTrajectoryFrame GetFrame(int i)
{
var handle = Native.ZkCutsceneCamera_getFrame(Handle, (ulong)i);
return new CameraTrajectoryFrame(Native.ZkObject_takeRef(handle));
Expand Down
90 changes: 45 additions & 45 deletions ZenKit/Vobs/Npc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public interface ISlot
{
bool Used { get; set; }
string Name { get; set; }
Item? Item { get; set; }
IItem? Item { get; set; }
bool InInventory { get; set; }
}

Expand All @@ -99,14 +99,14 @@ public string Name
set => Native.ZkNpcSlot_setName(handle, value);
}

public Item? Item
public IItem? Item
{
get
{
var val = Native.ZkNpcSlot_getItem(handle);
return val == UIntPtr.Zero ? null : new Item(Native.ZkObject_takeRef(val));
}
set => Native.ZkNpcSlot_setItem(handle, value?.Handle ?? UIntPtr.Zero);
set => Native.ZkNpcSlot_setItem(handle, value == null ? UIntPtr.Zero : ((Item)value).Handle);
}

public bool InInventory
Expand Down Expand Up @@ -242,18 +242,18 @@ public interface INpc : IVirtualObject
int BsInterruptableOverride { get; set; }
int NpcType { get; set; }
int SpellMana { get; set; }
VirtualObject? CarryVob { get; set; }
VirtualObject? Enemy { get; set; }
IVirtualObject? CarryVob { get; set; }
IVirtualObject? Enemy { get; set; }
int OverlayCount { get; }
List<string> Overlays { get; set; }
int TalentCount { get; }
List<Talent> Talents { get; set; }
List<ITalent> Talents { get; set; }
int ItemCount { get; }
List<Item> Items { get; set; }
List<IItem> Items { get; set; }
int SlotCount { get; }
List<Slot> Slots { get; }
List<ISlot> Slots { get; }
int NewsCount { get; }
List<News> News { get; }
List<INews> News { get; }
List<int> Protection { get; set; }
List<int> Attributes { get; set; }
List<int> HitChance { get; set; }
Expand All @@ -265,24 +265,24 @@ public interface INpc : IVirtualObject
void RemoveOverlay(int i);
void SetOverlay(int i, string overlay);
void AddOverlay(string overlay);
Talent GetTalent(int i);
ITalent GetTalent(int i);
void ClearTalents();
void RemoveTalent(int i);
void SetTalent(int i, Talent talent);
void AddTalent(Talent talent);
Item GetItem(int i);
void SetTalent(int i, ITalent talent);
void AddTalent(ITalent talent);
IItem GetItem(int i);
void ClearItems();
void RemoveItem(int i);
void SetItem(int i, Item item);
void AddItem(Item item);
Slot GetSlot(int i);
void SetItem(int i, IItem item);
void AddItem(IItem item);
ISlot GetSlot(int i);
void ClearSlots();
void RemoveSlot(int i);
Slot AddSlot();
News GetNews(int i);
ISlot AddSlot();
INews GetNews(int i);
void ClearNews();
void RemoveNews(int i);
News AddNews();
INews AddNews();
int GetProtection(int i);
void SetProtection(int i, int v);
int GetAttribute(int i);
Expand Down Expand Up @@ -581,24 +581,24 @@ public int SpellMana
set => Native.ZkNpc_setSpellMana(Handle, value);
}

public VirtualObject? CarryVob
public IVirtualObject? CarryVob
{
get
{
var val = Native.ZkNpc_getCarryVob(Handle);
return VirtualObject.FromNative(Native.ZkObject_takeRef(val));
}
set => Native.ZkNpc_setCarryVob(Handle, value?.Handle ?? System.UIntPtr.Zero);
set => Native.ZkNpc_setCarryVob(Handle, value == null ? UIntPtr.Zero : ((VirtualObject)value).Handle);
}

public VirtualObject? Enemy
public IVirtualObject? Enemy
{
get
{
var val = Native.ZkNpc_getEnemy(Handle);
return VirtualObject.FromNative(Native.ZkObject_takeRef(val));
}
set => Native.ZkNpc_setEnemy(Handle, value?.Handle ?? System.UIntPtr.Zero);
set => Native.ZkNpc_setEnemy(Handle, value == null ? UIntPtr.Zero : ((VirtualObject)value).Handle);
}


Expand Down Expand Up @@ -653,11 +653,11 @@ public void AddOverlay(string overlay)

public int TalentCount => (int)Native.ZkNpc_getTalentCount(Handle);

public List<Talent> Talents
public List<ITalent> Talents
{
get
{
var talents = new List<Talent>();
var talents = new List<ITalent>();

for (var i = 0; i < TalentCount; ++i)
{
Expand All @@ -675,7 +675,7 @@ public List<Talent> Talents
}


public Talent GetTalent(int i)
public ITalent GetTalent(int i)
{
return new Talent(Native.ZkObject_takeRef(Native.ZkNpc_getTalent(Handle, (ulong)i)));
}
Expand All @@ -690,23 +690,23 @@ public void RemoveTalent(int i)
Native.ZkNpc_removeTalent(Handle, (ulong)i);
}

public void SetTalent(int i, Talent talent)
public void SetTalent(int i, ITalent talent)
{
Native.ZkNpc_setTalent(Handle, (ulong)i, talent.Handle);
Native.ZkNpc_setTalent(Handle, (ulong)i, ((Talent)talent).Handle);
}

public void AddTalent(Talent talent)
public void AddTalent(ITalent talent)
{
Native.ZkNpc_addTalent(Handle, talent.Handle);
Native.ZkNpc_addTalent(Handle, ((Talent)talent).Handle);
}

public int ItemCount => (int)Native.ZkNpc_getItemCount(Handle);

public List<Item> Items
public List<IItem> Items
{
get
{
var items = new List<Item>();
var items = new List<IItem>();

for (var i = 0; i < ItemCount; ++i)
{
Expand All @@ -723,7 +723,7 @@ public List<Item> Items
}


public Item GetItem(int i)
public IItem GetItem(int i)
{
return new Item(Native.ZkObject_takeRef(Native.ZkNpc_getItem(Handle, (ulong)i)));
}
Expand All @@ -738,23 +738,23 @@ public void RemoveItem(int i)
Native.ZkNpc_removeItem(Handle, (ulong)i);
}

public void SetItem(int i, Item item)
public void SetItem(int i, IItem item)
{
Native.ZkNpc_setItem(Handle, (ulong)i, item.Handle);
Native.ZkNpc_setItem(Handle, (ulong)i, ((Item)item).Handle);
}

public void AddItem(Item item)
public void AddItem(IItem item)
{
Native.ZkNpc_addItem(Handle, item.Handle);
Native.ZkNpc_addItem(Handle, ((Item)item).Handle);
}

public int SlotCount => (int)Native.ZkNpc_getSlotCount(Handle);

public List<Slot> Slots
public List<ISlot> Slots
{
get
{
var items = new List<Slot>();
var items = new List<ISlot>();

for (var i = 0; i < ItemCount; ++i)
{
Expand All @@ -765,7 +765,7 @@ public List<Slot> Slots
}
}

public Slot GetSlot(int i)
public ISlot GetSlot(int i)
{
return new Slot(Native.ZkNpc_getSlot(Handle, (ulong)i));
}
Expand All @@ -780,18 +780,18 @@ public void RemoveSlot(int i)
Native.ZkNpc_removeSlot(Handle, (ulong)i);
}

public Slot AddSlot()
public ISlot AddSlot()
{
return new Slot(Native.ZkNpc_addSlot(Handle));
}

public int NewsCount => (int)Native.ZkNpc_getNewsCount(Handle);

public List<News> News
public List<INews> News
{
get
{
var items = new List<News>();
var items = new List<INews>();

for (var i = 0; i < ItemCount; ++i)
{
Expand All @@ -802,7 +802,7 @@ public List<News> News
}
}

public News GetNews(int i)
public INews GetNews(int i)
{
return new News(Native.ZkNpc_getNews(Handle, (ulong)i));
}
Expand All @@ -817,7 +817,7 @@ public void RemoveNews(int i)
Native.ZkNpc_removeSlot(Handle, (ulong)i);
}

public News AddNews()
public INews AddNews()
{
return new News(Native.ZkNpc_addNews(Handle));
}
Expand Down
6 changes: 3 additions & 3 deletions ZenKit/Vobs/Trigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface ITrigger : IVirtualObject
float DamageThreshold { get; set; }
TimeSpan FireDelay { get; set; }
float NextTimeTriggerable { get; set; }
VirtualObject? OtherVob { get; set; }
IVirtualObject? OtherVob { get; set; }
int CountCanBeActivated { get; set; }
bool IsEnabled { get; set; }
}
Expand Down Expand Up @@ -134,14 +134,14 @@ public float NextTimeTriggerable
set => Native.ZkTrigger_setNextTimeTriggerable(Handle, value);
}

public VirtualObject? OtherVob
public IVirtualObject? OtherVob
{
get
{
var val = Native.ZkTrigger_getOtherVob(Handle);
return VirtualObject.FromNative(Native.ZkObject_takeRef(val));
}
set => Native.ZkTrigger_setOtherVob(Handle, value?.Handle ?? UIntPtr.Zero);
set => Native.ZkTrigger_setOtherVob(Handle, value == null ? UIntPtr.Zero : ((VirtualObject)value).Handle);
}

public int CountCanBeActivated
Expand Down
Loading

0 comments on commit 90685cb

Please sign in to comment.