/// <summary> /// Adds a creature to a single tile with only the /// most basic information. Note: Used for speeding up /// loading spawns. /// </summary> /// <param name="creature">Creature to add.</param> /// <param name="position">Position to add creature.</param> public void AddCachedCreature(Creature creature, Position position) { lock (lockThis) { creature.World = this; creaturesOnline.Add(creature.GetID(), creature); creature.Finder = pathFinder; creature.LogedIn = true; gameMap.AddThing(creature, position); } }
/// <summary> /// Update the creature's direction. /// </summary> /// <param name="creature">The creature whose direction to update.</param> /// <param name="direction">The new direction.</param> /// <param name="stackpos">The creature's stack position.</param> /// <param name="position">The creature's position.</param> public void UpdateCreatureDirection(Creature creature, Direction direction, byte stackpos, Position position) { UpdateThingHeaders(position, UpdateThing.UPDATE, stackpos); AddCreatureDirection(direction, creature.GetID()); }
/// <summary> /// Add a creature to the player's client on the map. /// </summary> /// <param name="creature">The creature to add.</param> /// <param name="knowsCreature">Whether the player knows the creature.</param> public void AddTileCreature(Creature creature, bool knowsCreature) { netmsg.AddByte(0xFB); if (knowsCreature) { netmsg.AddU32(creature.GetID()); } else { netmsg.AddU32(0); } netmsg.AddU32(creature.GetID()); netmsg.AddStringZ(creature.Name, 30); netmsg.AddByte((byte)creature.CurrentHealthStatus); netmsg.AddByte((byte)creature.CurrentDirection); AddOutfit(creature); netmsg.AddByte(creature.GetLightLevel()); }
/// <summary> /// Adds the protocol information for moving a creature. /// </summary> /// <param name="direction">The new direction of the creature.</param> /// <param name="creature">The creature to move.</param> /// <param name="oldPos">Creature's old position.</param> /// <param name="newPos">Creature's new position.</param> /// <param name="oldStackpos">Creature's old stack position.</param> /// <param name="newStackpos">Creature's new stack position.</param> public void AddCreatureMove(Direction direction, Creature creature, Position oldPos, Position newPos, byte oldStackpos, byte newStackpos) { RemoveThing(oldPos, oldStackpos); UpdateThingHeaders(newPos, UpdateThing.ADD, newStackpos); AddCreatureDirection(direction, creature.GetID()); }
/// <summary> /// Adds the headers for updating a creature. /// </summary> /// <param name="c">The creature to update.</param> /// <param name="type">The type of update being done.</param> private void UpdateCreatureHeaders(Creature creature, UpdateCreature type) { netmsg.AddU16(0x32); //Update header netmsg.AddU32(creature.GetID()); netmsg.AddByte((byte)type); }
/// <summary> /// Removes the creature from the game world and only /// appends the data to the ThingSet without reseting or sending it. /// </summary> /// <param name="creature">The creature to remove.</param> /// <param name="tSet">A reference for which things to notify of the /// creature's removal.</param> private void AppendRemoveCreature(Creature creature) { creaturesOnline.Remove(creature.GetID()); creature.LogedIn = false; byte stackpos = gameMap.GetStackPosition(creature, creature.CurrentPosition); ThingSet tSet = gameMap.GetThingsInVicinity(creature.CurrentPosition); foreach (Monster summon in creature.GetSummons()) { summon.SetMaster(null); } foreach (Thing thing in tSet.GetThings()) { thing.RemoveThing(creature.CurrentPosition, stackpos); } gameMap.RemoveThing(creature, creature.CurrentPosition); }
/// <summary> /// Have a creature set its target that it will be attacking. /// </summary> /// <param name="creature">The creature attacking.</param> /// <param name="target">The creature who is being attacked.</param> public virtual void HandleCreatureTarget(Creature creature, Creature target) { if (target == null) { throw new Exception("Target is null in HandleCreatureTarget()"); } HandleCreatureTarget(creature, target.GetID()); }