iso2/scene/SwapHouse.cs
public class SwapHouse : Component {
[Property] public GameObject HouseExt;
[Property] public GameObject HouseInt;
[Property] public PacViewNode PacEntry;
[Property] public GameObject IsoEntry;
[Property, Change(nameof(StartSwap))] public bool InHouse {get; set;}
public void StartSwap() {
if (InHouse) {
Switch = () => {
HouseExt.Enabled = false;
HouseInt.Enabled = true;
BasePlayer.Local.IsoEntity.Components.Get<NpcMovement>().Path.Clear();
BasePlayer.Local.Isometric = false;
PacEntry.ConnectToNode();
};
} else {
Switch = () => {
HouseInt.Enabled = false;
HouseExt.Enabled = true;
BasePlayer.Local.GameObject.SetParent(null);
BasePlayer.Local.Isometric = true;
BasePlayer.Local.WorldTransform = IsoEntry.WorldTransform.WithRotation(Rotation.Identity);
BasePlayer.Local.IsoEntity.WorldTransform = IsoEntry.WorldTransform;
BasePlayer.Local.GameObject.Enabled = false;
BasePlayer.Local.GameObject.Enabled = true;
};
}
FadeOut = 1f;
Switching = true;
}
private bool Switching;
private Action Switch;
private TimeUntil FadeOut;
private TimeUntil FadeIn;
protected override void OnUpdate() {
if (!Switching)
return;
BasePlayer.Local.IsoCamera.Fade = -FadeOut.Fraction;
BasePlayer.Local.PacCamera.Fade = -FadeOut.Fraction;
if (!FadeOut) {
FadeIn = 1f;
return;
}
Switch?.Invoke();
Switch = null;
BasePlayer.Local.IsoCamera.Fade = -1 + FadeIn.Fraction;
BasePlayer.Local.PacCamera.Fade = -1 + FadeIn.Fraction;
if (!FadeIn)
return;
Switching = false;
base.OnUpdate();
}
}