/// <summary> /// The client will lose control of its current NPC and move into spectator mode (free view). /// </summary> public void SetToSpectate(World world, Vec3f position, Angles angles) { if (world == null) { throw new Exception("World is null!"); } if (!world.IsCreated) { throw new Exception("World is not created!"); } if (this.isSpectating && specWorld == world) { SpecSetPosAng(position, angles); return; } this.specPos = position.ClampToWorldLimits(); this.specAng = angles.Clamp(); pSetToSpectate(world, specPos, specAng); }
/// <summary> Spawns the Vob in the given world at the given position & direction. </summary> public virtual void Spawn(World world, Vec3f position, Angles angles) { if (world == null) { throw new ArgumentNullException("World is null!"); } if (this.instance == null) { throw new Exception("Vob has no Instance!"); } if (this.ScriptObject == null) { throw new Exception("Vob has no ScriptObject!"); } if (this.isCreated) { throw new Exception("Vob is already spawned!"); } Vec3f spawnPos = position.ClampToWorldLimits(); Angles spawnAng = angles.Clamp(); this.pBeforeSpawn(world, spawnPos, spawnAng); this.pos = spawnPos; this.ang = spawnAng; world.AddVob(this); this.world = world; this.isCreated = true; this.pAfterSpawn(world, spawnPos, spawnAng); this.OnSpawn?.Invoke(this, world, position, angles); sOnSpawn?.Invoke(this, world, position, angles); }
/// <summary> /// Spawns the NPC in the given world at the given position & direction. /// If the NPC is a player, the spawn will be postponed until the client has loaded the map. /// </summary> public override void Spawn(World world, Vec3f position, Angles angles) { if (this.IsPlayer) { if (world == null) { throw new ArgumentNullException("World is null!"); } if (this.Instance == null) { throw new Exception("Vob has no Instance!"); } if (this.ScriptObject == null) { throw new Exception("Vob has no ScriptObject!"); } if (this.isCreated) { throw new Exception("Vob is already spawned!"); } this.pos = position.ClampToWorldLimits(); this.ang = angles.Clamp(); this.world = world; // wait until the client has loaded the map World.Messages.WriteLoadWorld(this.client, world); // tell the client to change worlds first } else { base.Spawn(world, position, angles); world.AddToNPCCells(this); } }
internal void SetPosAng(Vec3f position, Angles angles, GameClient exclude) { this.pos = position.ClampToWorldLimits(); this.ang = angles.Clamp(); if (this.isCreated && !this.IsStatic) { this.world.UpdateVobCell(this, pos); if (this is NPC) { this.world.UpdateNPCCell((NPC)this, pos); } bool updateVis; if (lastUpdatePos.GetDistancePlanar(this.pos) > 100) { updateVis = true; lastUpdatePos = this.pos; CleanClientList(); } else { updateVis = false; } if (visibleClients.Count > 0 || targetOf.Count > 0) { this.WritePosAngMessage(exclude); } if (updateVis) { UpdateClientList(); } } }
public void SpecSetPosAng(Vec3f position, Angles angles) { this.specPos = position.ClampToWorldLimits(); this.specAng = angles.Clamp(); pSpecSetPosAng(); }
public void SpecSetDir(Angles angles) { this.specAng = angles.Clamp(); pSpecSetAng(); }
/// <summary> Sets the rotational angles of this vob. Pitch (up-down), Yaw (left-right), Roll (sideways). </summary> public void SetAngles(Angles angles) { this.ang = angles.Clamp(); pSetAngles(); }