Skip to content

Commit

Permalink
[LotView, TS1] Fix various prop/anim bugs in TS1, correctly update po…
Browse files Browse the repository at this point in the history
…sition with plate stacking in 2d
  • Loading branch information
riperiperi committed Nov 16, 2019
1 parent 2496bbc commit 4d832d0
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion TSOClient/tso.simantics/VM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public void Update()
allSounds.AddRange(ent.SoundThreads.Select(x => x.Sound));
}

if (SpeedMultiplier < 1 && LastFrameSpeed >= 1) allSounds.ForEach((x) => x.Pause());
if (SpeedMultiplier < 1 && SpeedMultiplier > -2 && LastFrameSpeed >= 1) allSounds.ForEach((x) => x.Pause());
else if (SpeedMultiplier >= 1 && LastFrameSpeed < 1) allSounds.ForEach((x) => x.Resume());
LastFrameSpeed = SpeedMultiplier;
}
Expand Down
20 changes: 12 additions & 8 deletions TSOClient/tso.simantics/entities/VMAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,11 +1057,13 @@ public override bool PlaceInSlot(VMEntity obj, int slot, bool cleanOld, VMContex
{
obj.WorldUI.Container = this.WorldUI;
obj.WorldUI.ContainerSlot = slot;
if (obj.WorldUI is ObjectComponent)
HandObject.RecurseSlotFunc(contained =>
{
var objC = (ObjectComponent)obj.WorldUI;
objC.ForceDynamic = true;
}
if (contained is VMGameObject)
{
((ObjectComponent)contained.WorldUI).ForceDynamic = true;
}
});
}
obj.Position = Position; //TODO: is physical position the same as the slot offset position?
if (cleanOld) obj.PositionChange(context, false);
Expand Down Expand Up @@ -1090,11 +1092,13 @@ public override void ClearSlot(int slot)
HandObject.WorldUI.Container = null;
HandObject.WorldUI.ContainerSlot = 0;

if (HandObject.WorldUI is ObjectComponent)
HandObject.RecurseSlotFunc(contained =>
{
var objC = (ObjectComponent)HandObject.WorldUI;
objC.ForceDynamic = false;
}
if (contained is VMGameObject)
{
((ObjectComponent)contained.WorldUI).ForceDynamic = false;
}
});
}

HandObject = null;
Expand Down
15 changes: 15 additions & 0 deletions TSOClient/tso.simantics/entities/VMEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,21 @@ public void RecurseSlotPositionChange(VMContext context, bool noEntryPoint)
PositionChange(context, noEntryPoint);
}

public void RecurseSlotFunc(Action<VMEntity> func)
{
func(this);
var count = TotalSlots();

for (int i = 0; i < count; i++)
{
var item = GetSlot(i);
if (item != null)
{
item.RecurseSlotFunc(func);
}
}
}

public bool WillLoopSlot(VMEntity test)
{
if (test == this) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static VMPrimitiveExitCode ExecuteGeneric(VMStackFrame context, VMPrimiti
{
context.VM.GlobalBlockingDialog = context.Caller;
context.VM.LastSpeedMultiplier = context.VM.SpeedMultiplier;
context.VM.SpeedMultiplier = -1;
context.VM.SpeedMultiplier = -2;
}
return VMPrimitiveExitCode.CONTINUE_NEXT_TICK;
}
Expand Down
2 changes: 2 additions & 0 deletions TSOClient/tso.vitaboy.model/Animation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class Animation
/// </summary>
public int NumFrames { get; set; }

public BCF ParentBCF;

/// <summary>
/// Reads an animation from a stream.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions TSOClient/tso.vitaboy.model/Appearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class Appearance
public int Type;
public int Zero;

public BCF ParentBCF;

/// <summary>
/// Gets the ContentID instance for this appearance.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions TSOClient/tso.vitaboy.model/Skeleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class Skeleton
public Bone[] Bones;
public Bone RootBone;

public BCF ParentBCF;

/// <summary>
/// Gets a bone from this Skeleton instance.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions TSOClient/tso.world/components/ObjectComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ public bool ForceDynamic
{
get
{
return _ForceDynamic || Headline != null || Mode.HasFlag(ComponentRenderMode._3D);
var bottomMost = GetBottomContainer();
return _ForceDynamic || Headline != null || Mode.HasFlag(ComponentRenderMode._3D) || bottomMost is AvatarComponent;
}
set
{
Expand All @@ -221,7 +222,6 @@ public bool ForceDynamic
}
_ForceDynamic = value;
}

}

private ulong _DynamicSpriteFlags = 0x00000000;
Expand Down

0 comments on commit 4d832d0

Please sign in to comment.