90 lines
3.8 KiB
C#
90 lines
3.8 KiB
C#
public class MinEventActionRespawnEntity : MinEventActionTargetedBase
|
|
{
|
|
public override void Execute(MinEventParams _params)
|
|
{
|
|
//Log.Out("MinEventActionRespawnEntity-Execute START");
|
|
|
|
if (!GameManager.IsDedicatedServer)
|
|
{
|
|
EntityNPCRebirth entity = _params.Self as EntityNPCRebirth;
|
|
//Log.Out("MinEventActionRespawnEntity-Execute Entity: " + entity.EntityName);
|
|
if (entity == null)
|
|
{
|
|
//Log.Out("MinEventActionRespawnEntity-Execute 1");
|
|
return;
|
|
}
|
|
|
|
if (entity.LeaderUtils.Owner)
|
|
{
|
|
//Log.Out("MinEventActionRespawnEntity-Execute flLeader: " + flLeader);
|
|
//Log.Out("MinEventActionRespawnEntity-Execute 3");
|
|
float flX = 0; //entity.Buffs.GetCustomVar("$FR_NPC_RespawnX");
|
|
float flY = 0; //entity.Buffs.GetCustomVar("$FR_NPC_RespawnY");
|
|
float flZ = 0; //entity.Buffs.GetCustomVar("$FR_NPC_RespawnZ");
|
|
float flRotY = 0; //entity.Buffs.GetCustomVar("$FR_NPC_RespawnRotY");
|
|
|
|
foreach (RebirthManager.hireInfo hire in RebirthManager.playerHires)
|
|
{
|
|
if (hire.hireID == entity.entityId)
|
|
{
|
|
flX = hire.reSpawnPosition.x;
|
|
flY = hire.reSpawnPosition.y;
|
|
flZ = hire.reSpawnPosition.z;
|
|
flRotY = hire.reSpawnRotation.y;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//Log.Out("MinEventActionRespawnEntity-Execute X: " + flX);
|
|
//Log.Out("MinEventActionRespawnEntity-Execute Y: " + flY);
|
|
//Log.Out("MinEventActionRespawnEntity-Execute Z: " + flZ);
|
|
|
|
if (flX != 0 && flY != 0 && flZ != 0)
|
|
{
|
|
//Log.Out("MinEventActionRespawnEntity-Execute 4");
|
|
Vector3 vector = new Vector3(flX, flY, flZ);
|
|
|
|
if (entity.PhysicsTransform != null)
|
|
{
|
|
entity.PhysicsTransform.gameObject.layer = 15;
|
|
}
|
|
entity.emodel.SetAlive();
|
|
|
|
entity.motion = Vector3.zero;
|
|
entity.navigator?.clearPath();
|
|
entity.moveHelper?.Stop();
|
|
entity.speedForward = 0;
|
|
entity.speedStrafe = 0;
|
|
//entity.motion = Vector3.zero;
|
|
//entity.navigator?.clearPath();
|
|
entity.LeaderUtils.IsTeleporting = true;
|
|
entity.isHirable = false;
|
|
entity.SetPosition(vector, true);
|
|
entity.rotation.y = flRotY;
|
|
entity.ClearDamagedTarget();
|
|
entity.ClearStun();
|
|
entity.numReposition = 1;
|
|
|
|
entity.LeaderUtils.IsTeleporting = false;
|
|
|
|
entity.Buffs.AddBuff("FuriousRamsayDeathParticle");
|
|
|
|
entity.Buffs.SetCustomVar("$FR_NPC_RespawnCommandActivation", 0);
|
|
////Log.Out("MinEventActionRespawnEntity-Execute EntityID: " + entity.entityId);
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("MinEventActionRespawnEntity-Execute 5");
|
|
entity.bWillRespawn = false;
|
|
GameManager.Instance.World.RemoveEntity(entity.entityId, EnumRemoveEntityReason.Unloaded);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("MinEventActionRespawnEntity-Execute 7");
|
|
entity.bWillRespawn = false;
|
|
GameManager.Instance.World.RemoveEntity(entity.entityId, EnumRemoveEntityReason.Unloaded);
|
|
}
|
|
}
|
|
}
|
|
} |