public CreatureGeoInfo AddCreature(Creature _creature, Point _worldCoords, Point _liveCoords, WorldLayer _layer = null) { if(_creature is FakedCreature) { _creature = (Creature)((FakedCreature)_creature).Essence.Clone(World.TheWorld.Avatar); } if(InfoByCreature.ContainsKey(_creature)) { throw new ApplicationException(); } if(_layer==null) { _layer = World.TheWorld.Avatar.GeoInfo.Layer; } CreatureGeoInfo geoInfo; if(!OutOfScope.TryGetValue(_creature, out geoInfo)) { geoInfo = new CreatureGeoInfo(_creature, _worldCoords) {Layer = _layer}; } else { OutOfScope.Remove(_creature); } InfoByCreature.Add(_creature, geoInfo); PointByCreature.Add(geoInfo, _worldCoords); if (_creature is AbstractDummyCreature) { List<CreatureGeoInfo> list; if(!DummyCreatureByPoint.TryGetValue(_worldCoords, out list)) { list = new List<CreatureGeoInfo>(); DummyCreatureByPoint.Add(_worldCoords, list); } list.Add(geoInfo); } else { CreatureByPoint.Add(_worldCoords, geoInfo); } geoInfo.LiveCoords = _liveCoords; _creature.GeoInfo = geoInfo; geoInfo[0,0].ResetCached(); if (_creature.GeoInfo.WorldCoords != _worldCoords) { throw new ApplicationException(); } return geoInfo; }
public CreatureGeoInfo AddCreature(Creature _creature, Point _worldCoords, Point _liveCoords, WorldLayer _layer = null) { if (_creature is FakedCreature) { _creature = (Creature)((FakedCreature)_creature).Essence.Clone(World.TheWorld.Avatar); } if (InfoByCreature.ContainsKey(_creature)) { throw new ApplicationException(); } if (_layer == null) { _layer = World.TheWorld.Avatar.GeoInfo.Layer; } CreatureGeoInfo geoInfo; if (!OutOfScope.TryGetValue(_creature, out geoInfo)) { geoInfo = new CreatureGeoInfo(_creature, _worldCoords) { Layer = _layer }; } else { OutOfScope.Remove(_creature); } InfoByCreature.Add(_creature, geoInfo); PointByCreature.Add(geoInfo, _worldCoords); if (_creature is AbstractDummyCreature) { List <CreatureGeoInfo> list; if (!DummyCreatureByPoint.TryGetValue(_worldCoords, out list)) { list = new List <CreatureGeoInfo>(); DummyCreatureByPoint.Add(_worldCoords, list); } list.Add(geoInfo); } else { CreatureByPoint.Add(_worldCoords, geoInfo); } geoInfo.LiveCoords = _liveCoords; _creature.GeoInfo = geoInfo; geoInfo[0, 0].ResetCached(); if (_creature.GeoInfo.WorldCoords != _worldCoords) { throw new ApplicationException(); } return(geoInfo); }