Skip to content

Commit

Permalink
[#12] feat(VirtualObject): Add interfaces for all Vob types
Browse files Browse the repository at this point in the history
* add(I*VirtualObject): Add interfaces for all Vob types.

* update(I*VirtualObject): Checked on Fields returning classes. Altered them to remove interfaces instead.
  • Loading branch information
JaXt0r authored Sep 20, 2024
1 parent d67fe12 commit fa8d331
Show file tree
Hide file tree
Showing 29 changed files with 735 additions and 171 deletions.
9 changes: 7 additions & 2 deletions ZenKit/Vobs/Animate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

namespace ZenKit.Vobs
{
public class Animate : VirtualObject
public interface IAnimate : IVirtualObject
{
bool StartOn { get; set; }
}

public class Animate : VirtualObject, IAnimate
{
public Animate() : base(Native.ZkVirtualObject_new(VirtualObjectType.zCVobAnimate))
{
Expand Down Expand Up @@ -33,4 +38,4 @@ protected override void Delete()
Native.ZkAnimate_del(Handle);
}
}
}
}
19 changes: 17 additions & 2 deletions ZenKit/Vobs/CodeMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@

namespace ZenKit.Vobs
{
public class CodeMaster : VirtualObject
public interface ICodeMaster : IVirtualObject
{
string Target { get; set; }
bool Ordered { get; set; }
bool FirstFalseIsFailure { get; set; }
string FailureTarget { get; set; }
bool UntriggeredCancels { get; set; }
int SlaveCount { get; }
List<string> Slaves { get; }
string GetSlave(int i);
void AddSlave(string slave);
void RemoveSlave(int i);
void RemoveSlaves(Predicate<string> pred);
}

public class CodeMaster : VirtualObject, ICodeMaster
{
private static readonly Native.Callbacks.ZkStringEnumerator RemoveSlavesEnumerator = _enumerateSlavesHandler;

Expand Down Expand Up @@ -111,4 +126,4 @@ private static bool _enumerateSlavesHandler(IntPtr ctx, IntPtr ptr)
return cb(ptr.MarshalAsString()!);
}
}
}
}
20 changes: 16 additions & 4 deletions ZenKit/Vobs/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@

namespace ZenKit.Vobs
{
public class Container : InteractiveObject
public interface IContainer : IInteractiveObject
{
bool IsLocked { get; set; }
string Key { get; set; }
string PickString { get; set; }
string Contents { get; set; }
int ItemCount { get; }
List<IItem> Items { get; }
void AddItem(Item item);
void RemoveItem(int i);
}

public class Container : InteractiveObject, IContainer
{
public Container() : base(Native.ZkVirtualObject_new(VirtualObjectType.oCMobContainer))
{
Expand Down Expand Up @@ -49,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 All @@ -80,4 +92,4 @@ protected override void Delete()
Native.ZkContainer_del(Handle);
}
}
}
}
52 changes: 46 additions & 6 deletions ZenKit/Vobs/CutsceneCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,24 @@ public enum CameraMotion
Custom = 6
}

public class CameraTrajectoryFrame : VirtualObject
public interface ICameraTrajectoryFrame : IVirtualObject
{
float Time { get; set; }
float RollAngle { get; set; }
float FovScale { get; set; }
CameraMotion MotionType { get; set; }
CameraMotion MotionTypeFov { get; set; }
CameraMotion MotionTypeRoll { get; set; }
CameraMotion MotionTypeTimeScale { get; set; }
float Tension { get; set; }
float CamBias { get; set; }
float Continuity { get; set; }
float TimeScale { get; set; }
bool TimeFixed { get; set; }
Matrix4x4 OriginalPose { get; set; }
}

public class CameraTrajectoryFrame : VirtualObject, ICameraTrajectoryFrame
{
public CameraTrajectoryFrame() : base(Native.ZkVirtualObject_new(VirtualObjectType.zCCamTrj_KeyFrame))
{
Expand Down Expand Up @@ -129,7 +146,30 @@ protected override void Delete()
}
}

public class CutsceneCamera : VirtualObject
public interface ICutsceneCamera : IVirtualObject
{
CameraTrajectory TrajectoryFOR { get; set; }
CameraTrajectory TargetTrajectoryFOR { get; set; }
CameraLoopType LoopMode { get; set; }
CameraLerpType LerpMode { get; set; }
bool IgnoreFORVobRotation { get; set; }
bool IgnoreFORVobRotationTarget { get; set; }
bool Adapt { get; set; }
bool EaseFirst { get; set; }
bool EaseLast { get; set; }
float TotalDuration { get; set; }
string AutoFocusVob { get; set; }
bool AutoPlayerMovable { get; set; }
bool AutoUntriggerLast { get; set; }
float AutoUntriggerLastDelay { get; set; }
int PositionCount { get; }
int TargetCount { get; }
int FrameCount { get; }
List<ICameraTrajectoryFrame> Frames { get; }
ICameraTrajectoryFrame GetFrame(int i);
}

public class CutsceneCamera : VirtualObject, ICutsceneCamera
{
public CutsceneCamera() : base(Native.ZkVirtualObject_new(VirtualObjectType.zCCSCamera))
{
Expand Down Expand Up @@ -239,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 @@ -255,10 +295,10 @@ 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));
}
}
}
}
11 changes: 9 additions & 2 deletions ZenKit/Vobs/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

namespace ZenKit.Vobs
{
public class Door : InteractiveObject
public interface IDoor : IInteractiveObject
{
bool IsLocked { get; set; }
string Key { get; set; }
string PickString { get; set; }
}

public class Door : InteractiveObject, IDoor
{
public Door() : base(Native.ZkVirtualObject_new(VirtualObjectType.oCMobDoor))
{
Expand Down Expand Up @@ -45,4 +52,4 @@ protected override void Delete()
Native.ZkDoor_del(Handle);
}
}
}
}
11 changes: 9 additions & 2 deletions ZenKit/Vobs/Earthquake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@

namespace ZenKit.Vobs
{
public class Earthquake : VirtualObject
public interface IEarthquake : IVirtualObject
{
float Radius { get; set; }
TimeSpan Duration { get; set; }
Vector3 Amplitude { get; set; }
}

public class Earthquake : VirtualObject, IEarthquake
{
public Earthquake() : base(Native.ZkVirtualObject_new(VirtualObjectType.zCEarthquake))
{
Expand Down Expand Up @@ -46,4 +53,4 @@ protected override void Delete()
Native.ZkEarthquake_del(Handle);
}
}
}
}
10 changes: 8 additions & 2 deletions ZenKit/Vobs/Fire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

namespace ZenKit.Vobs
{
public class Fire : InteractiveObject
public interface IFire : IInteractiveObject
{
string Slot { get; set; }
string VobTree { get; set; }
}

public class Fire : InteractiveObject, IFire
{
public Fire() : base(Native.ZkVirtualObject_new(VirtualObjectType.oCMobFire))
{
Expand Down Expand Up @@ -39,4 +45,4 @@ protected override void Delete()
Native.ZkFire_del(Handle);
}
}
}
}
38 changes: 32 additions & 6 deletions ZenKit/Vobs/InteractiveObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

namespace ZenKit.Vobs
{
public class InteractiveObject : MovableObject
public interface IInteractiveObject : IMovableObject
{
int State { get; set; }
string Target { get; set; }
string Item { get; set; }
string ConditionFunction { get; set; }
string OnStateChangeFunction { get; set; }
bool Rewind { get; set; }
}

public class InteractiveObject : MovableObject, IInteractiveObject
{
public InteractiveObject() : base(Native.ZkVirtualObject_new(VirtualObjectType.oCMobInter))
{
Expand Down Expand Up @@ -69,7 +79,11 @@ protected override void Delete()
}
}

public class Bed : InteractiveObject
public interface IBed : IInteractiveObject
{
}

public class Bed : InteractiveObject, IBed
{
public Bed() : base(Native.ZkVirtualObject_new(VirtualObjectType.oCMobBed))
{
Expand All @@ -80,7 +94,11 @@ internal Bed(UIntPtr handle) : base(handle)
}
}

public class Ladder : InteractiveObject
public interface ILadder : IInteractiveObject
{
}

public class Ladder : InteractiveObject, ILadder
{
public Ladder() : base(Native.ZkVirtualObject_new(VirtualObjectType.oCMobLadder))
{
Expand All @@ -91,7 +109,11 @@ internal Ladder(UIntPtr handle) : base(handle)
}
}

public class Switch : InteractiveObject
public interface ISwitch : IInteractiveObject
{
}

public class Switch : InteractiveObject, ISwitch
{
public Switch() : base(Native.ZkVirtualObject_new(VirtualObjectType.oCMobSwitch))
{
Expand All @@ -102,7 +124,11 @@ internal Switch(UIntPtr handle) : base(handle)
}
}

public class Wheel : InteractiveObject
public interface IWheel : IInteractiveObject
{
}

public class Wheel : InteractiveObject, IWheel
{
public Wheel() : base(Native.ZkVirtualObject_new(VirtualObjectType.oCMobWheel))
{
Expand All @@ -112,4 +138,4 @@ internal Wheel(UIntPtr handle) : base(handle)
{
}
}
}
}
11 changes: 9 additions & 2 deletions ZenKit/Vobs/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

namespace ZenKit.Vobs
{
public class Item : VirtualObject
public interface IItem : IVirtualObject
{
string Instance { get; set; }
int Amount { get; set; }
int Flags { get; set; }
}

public class Item : VirtualObject, IItem
{
public Item() : base(Native.ZkVirtualObject_new(VirtualObjectType.oCItem))
{
Expand Down Expand Up @@ -46,4 +53,4 @@ protected override void Delete()
Native.ZkItem_del(Handle);
}
}
}
}
9 changes: 7 additions & 2 deletions ZenKit/Vobs/LensFlare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

namespace ZenKit.Vobs
{
public class LensFlare : VirtualObject
public interface ILensFlare : IVirtualObject
{
string Effect { get; set; }
}

public class LensFlare : VirtualObject, ILensFlare
{
public LensFlare() : base(Native.ZkVirtualObject_new(VirtualObjectType.zCVobLensFlare))
{
Expand Down Expand Up @@ -34,4 +39,4 @@ protected override void Delete()
Native.ZkLensFlare_del(Handle);
}
}
}
}
9 changes: 7 additions & 2 deletions ZenKit/Vobs/Light.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ public bool CanMove
}
}

public class Light : VirtualObject, ILightPreset
public interface ILight : ILightPreset, IVirtualObject
{

}

public class Light : VirtualObject, ILight
{
public Light() : base(Native.ZkVirtualObject_new(VirtualObjectType.zCVobLight))
{
Expand Down Expand Up @@ -321,4 +326,4 @@ protected override void Delete()
Native.ZkLight_del(Handle);
}
}
}
}
Loading

0 comments on commit fa8d331

Please sign in to comment.