public void ExcludeCreature(Creature _creature) { _creature.ClearActPool(); var liveMapCell = _creature[0, 0]; liveMapCell.ResetCached(); var info = InfoByCreature[_creature]; OutOfScope.Add(_creature, info); InfoByCreature.Remove(_creature); PointByCreature.Remove(info); if (_creature is AbstractDummyCreature) { if (!DummyCreatureByPoint[info.WorldCoords].Remove(info)) { throw new ApplicationException(); } } else { if (!CreatureByPoint.Remove(info.WorldCoords)) { throw new ApplicationException(); } info.Layer[liveMapCell.MapBlockId].CreaturesAdd(_creature, liveMapCell.InBlockCoords); } info[0, 0].ResetCached(); info.LiveCoords = null; }
public void CreatureIsDead(Creature _creature) { var info = InfoByCreature[_creature]; _creature[0, 0].ResetCached(); _creature.GeoInfo = null; _creature.ClearActPool(); InfoByCreature.Remove(_creature); OutOfScope.Remove(_creature); if (!PointByCreature.Remove(info)) { throw new ApplicationException(); } if (_creature is AbstractDummyCreature) { if (!DummyCreatureByPoint[info.WorldCoords].Remove(info)) { throw new ApplicationException(); } } else { if (!CreatureByPoint.Remove(info.WorldCoords)) { throw new ApplicationException(); } } }
public void MoveCreature(Creature _creature, Point _worldCoord, WorldLayer _layer = null) { if (_layer == null) { _layer = World.TheWorld.Avatar.GeoInfo.Layer; } _creature[0, 0].ResetCached(); var info = InfoByCreature[_creature]; if (_creature.GeoInfo.WorldCoords != info.WorldCoords) { throw new ApplicationException(); } if (_layer != info.Layer) { if (_creature.IsAvatar) { //Если аватар ушел на другой уровень var allCreatures = InfoByCreature.Keys.ToArray(); foreach (var creature in allCreatures) { if (creature.IsAvatar) { continue; } if (creature is AbstractDummyCreature) { CreatureIsDead(creature); } else { ExcludeCreature(creature); } } info.Layer = _layer; World.TheWorld.LiveMap.Reset(); } else { throw new NotImplementedException(); } } else { if (info.WorldCoords == _worldCoord) { throw new ApplicationException(); } PointByCreature.Remove(info); var oldBlockId = BaseMapBlock.GetBlockId(info.WorldCoords); var newBlockId = BaseMapBlock.GetBlockId(_worldCoord); var delta = _worldCoord - info.WorldCoords; if (oldBlockId != newBlockId) { var newCell = info[delta]; if (_creature.IsAvatar) { World.TheWorld.LiveMap.AvatarChangesBlock(oldBlockId, newBlockId, newCell.LiveMapBlock.LiveMapBlockId); } } if (info.LiveCoords != null) { if (_creature is AbstractDummyCreature) { if (!DummyCreatureByPoint[info.WorldCoords].Remove(info)) { throw new ApplicationException(); } List <CreatureGeoInfo> list; if (!DummyCreatureByPoint.TryGetValue(_worldCoord, out list)) { list = new List <CreatureGeoInfo>(); DummyCreatureByPoint.Add(_worldCoord, list); } list.Add(info); } else { if (!CreatureByPoint.Remove(info.WorldCoords)) { throw new ApplicationException(); } CreatureByPoint.Add(_worldCoord, info); } info.LiveCoords += delta; info.WorldCoords = _worldCoord; PointByCreature.Add(info, _worldCoord); } } if (info.LiveCoords != null) { _creature[0, 0].ResetCached(); if (_creature.IsAvatar) { MessageManager.SendMessage(this, WorldMessage.AvatarMove); } } }