Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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();
                }
            }
        }
Esempio n. 3
0
        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);
        }