Exemple #1
0
        public void AddInfluence(Actor self, IOccupySpace ios)
        {
            foreach (var c in ios.OccupiedCells())
            {
                var uv = c.Cell.ToMPos(map);
                if (!influence.Contains(uv))
                {
                    continue;
                }

                var layer = c.Cell.Layer == 0 ? influence : customInfluence[c.Cell.Layer];
                layer[uv] = new InfluenceNode {
                    Next = layer[uv], SubCell = c.SubCell, Actor = self
                };

                List <CellTrigger> triggers;
                if (cellTriggerInfluence.TryGetValue(c.Cell, out triggers))
                {
                    foreach (var t in triggers)
                    {
                        t.Dirty = true;
                    }
                }

                if (CellUpdated != null)
                {
                    CellUpdated(c.Cell);
                }
            }
        }
Exemple #2
0
        public void AddInfluence(Actor self, IOccupySpace ios)
        {
            foreach (var c in ios.OccupiedCells())
            {
                var uv    = c.Cell.ToMPos(map);
                var layer = influence[c.Cell.Layer];
                if (!layer.Contains(uv))
                {
                    continue;
                }

                layer[uv] = new InfluenceNode {
                    Next = layer[uv], SubCell = c.SubCell, Actor = self
                };

                if (cellTriggerInfluence.TryGetValue(c.Cell, out var triggers))
                {
                    foreach (var t in triggers)
                    {
                        t.Dirty = true;
                    }
                }

                CellUpdated?.Invoke(c.Cell);
            }
        }
Exemple #3
0
        public void RemoveInfluence(Actor self, IOccupySpace ios)
        {
            foreach (var c in ios.OccupiedCells())
            {
                var uv    = c.Cell.ToMPos(map);
                var layer = influence[c.Cell.Layer];
                if (!layer.Contains(uv))
                {
                    continue;
                }

                var temp = layer[uv];
                RemoveInfluenceInner(ref temp, self);
                layer[uv] = temp;

                if (cellTriggerInfluence.TryGetValue(c.Cell, out var triggers))
                {
                    foreach (var t in triggers)
                    {
                        t.Dirty = true;
                    }
                }

                CellUpdated?.Invoke(c.Cell);
            }
        }
Exemple #4
0
 public void RemoveInfluence(Actor self, IOccupySpace ios)
 {
     foreach (var c in ios.OccupiedCells())
     {
         RemoveInfluenceInner(ref influence[c.First.X, c.First.Y], self);
     }
 }
Exemple #5
0
        public void RemoveInfluence(Actor self, IOccupySpace ios)
        {
            foreach (var c in ios.OccupiedCells())
            {
                var uv = c.Cell.ToMPos(map);
                if (!influence.Contains(uv))
                {
                    continue;
                }

                var layer = c.Cell.Layer == 0 ? influence : customInfluence[c.Cell.Layer];
                var temp  = layer[uv];
                RemoveInfluenceInner(ref temp, self);
                layer[uv] = temp;

                List <CellTrigger> triggers;
                if (cellTriggerInfluence.TryGetValue(c.Cell, out triggers))
                {
                    foreach (var t in triggers)
                    {
                        t.Dirty = true;
                    }
                }

                if (CellUpdated != null)
                {
                    CellUpdated(c.Cell);
                }
            }
        }
Exemple #6
0
 public void AddToMaps(Actor self, IOccupySpace ios)
 {
     ActorMap.AddInfluence(self, ios);
     ActorMap.AddPosition(self, ios);
     ScreenMap.AddOrUpdate(self);
     //if(!self.Bounds.Size.IsEmpty)
     //ScreenMap.Add(self);
 }
Exemple #7
0
 public void Update(Actor self, IOccupySpace unit)
 {
     Remove(self, unit);
     if (!self.IsDead())
     {
         Add(self, unit);
     }
 }
Exemple #8
0
 public void RemoveFromMaps(Actor self, IOccupySpace ios)
 {
     ActorMap.RemoveInfluence(self, ios);
     ActorMap.RemovePosition(self, ios);
     ScreenMap.Remove(self);
     //if(!self.Bounds.Size.IsEmpty)
     //ScreenMap.Remove(self);
 }
Exemple #9
0
 public void RemoveInfluence(Actor self, IOccupySpace ios)
 {
     foreach (var c in ios.OccupiedCells())
     {
         var temp = influence[c.First];
         RemoveInfluenceInner(ref temp, self);
         influence[c.First] = temp;
     }
 }
Exemple #10
0
        public void UpdateMaps(Actor self, IOccupySpace ios)
        {
            if (!self.IsInWorld)
            {
                return;
            }

            ScreenMap.AddOrUpdate(self);
            ActorMap.UpdatePosition(self, ios);
        }
Exemple #11
0
 public void AddInfluence(Actor self, IOccupySpace ios)
 {
     foreach (var c in ios.OccupiedCells())
     {
         influence[c.First.X, c.First.Y] = new InfluenceNode {
             Next = influence[c.First.X, c.First.Y], SubCell = c.Second, Actor = self
         }
     }
     ;
 }
Exemple #12
0
 public void Remove(Actor self, IOccupySpace unit)
 {
     if (unit != null)
     {
         foreach (var c in unit.OccupiedCells())
         {
             RemoveInner(ref influence[c.First.X, c.First.Y], self);
         }
     }
 }
Exemple #13
0
        public void UpdateOccupiedCells(IOccupySpace ios)
        {
            if (CellUpdated == null)
            {
                return;
            }

            foreach (var c in ios.OccupiedCells())
            {
                CellUpdated(c.Cell);
            }
        }
Exemple #14
0
        /// <summary>
        /// 更新地图
        /// </summary>
        /// <param name="self"></param>
        /// <param name="ios"></param>
        public void UpdateMaps(Actor self, IOccupySpace ios)
        {
            if (!self.IsInWorld)
            {
                return;
            }
            //if (!self.Bounds.Size.IsEmpty)
            //ScreenMap.Update(self);

            ScreenMap.AddOrUpdate(self);
            ActorMap.UpdatePosition(self, ios);
        }
Exemple #15
0
 public void Add(Actor self, IOccupySpace unit)
 {
     if (unit != null)
     {
         foreach (var c in unit.OccupiedCells())
         {
             influence[c.First.X, c.First.Y] = new InfluenceNode {
                 next = influence[c.First.X, c.First.Y], subCell = c.Second, actor = self
             }
         }
     }
     ;
 }
Exemple #16
0
        public static int2 NearestCellTo(this IOccupySpace ios, int2 other)
        {
            var nearest         = ios.TopLeft;
            var nearestDistance = int.MaxValue;

            foreach (var cell in ios.OccupiedCells())
            {
                var dist = (other - cell.First).LengthSquared;
                if (dist < nearestDistance)
                {
                    nearest         = cell.First;
                    nearestDistance = dist;
                }
            }
            return(nearest);
        }
Exemple #17
0
        public void AddInfluence(Actor self, IOccupySpace ios)
        {
            foreach (var c in ios.OccupiedCells())
            {
                if (!map.Contains(c.First))
                {
                    continue;
                }

                influence[c.First] = new InfluenceNode {
                    Next = influence[c.First], SubCell = c.Second, Actor = self
                };

                List <CellTrigger> triggers;
                if (cellTriggerInfluence.TryGetValue(c.First, out triggers))
                {
                    foreach (var t in triggers)
                    {
                        t.Dirty = true;
                    }
                }
            }
        }
Exemple #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="self"></param>
        /// <param name="ios"></param>
        public void RemoveInfluence(Actor self, IOccupySpace ios)
        {
            foreach (var c in ios.OccupiedCells())
            {
                var uv = c.First.ToMPos(map);
                if (!influence.Contains(uv))
                {
                    continue;
                }

                var temp = influence[uv];
                RemoveInfluenceInner(ref temp, self);
                influence[uv] = temp;
                List <CellTrigger> triggers;
                if (cellTriggerInfluence.TryGetValue(c.First, out triggers))
                {
                    foreach (var t in triggers)
                    {
                        t.Dirty = true;
                    }
                }
            }
        }
Exemple #19
0
 public void Add( Actor self, IOccupySpace unit )
 {
     foreach( var c in unit.OccupiedCells() )
         influence[ c.X, c.Y ] = new InfluenceNode { next = influence[ c.X, c.Y ], actor = self };
 }
Exemple #20
0
 public void AddToMaps(Actor self, IOccupySpace ios)
 {
     ActorMap.AddInfluence(self, ios);
     ActorMap.AddPosition(self, ios);
     ScreenMap.AddOrUpdate(self);
 }
Exemple #21
0
 public void UpdatePosition(Actor a, IOccupySpace ios)
 {
     RemovePosition(a, ios);
     addActorPosition.Add(a);
 }
Exemple #22
0
 public void RemovePosition(Actor a, IOccupySpace ios)
 {
     removeActorPosition.Add(a);
 }
Exemple #23
0
        public void RemoveInfluence(Actor self, IOccupySpace ios)
        {
            foreach (var c in ios.OccupiedCells())
            {
                if (!map.Contains(c.First))
                    continue;

                var temp = influence[c.First];
                RemoveInfluenceInner(ref temp, self);
                influence[c.First] = temp;

                List<CellTrigger> triggers;
                if (cellTriggerInfluence.TryGetValue(c.First, out triggers))
                    foreach (var t in triggers)
                        t.Dirty = true;
            }
        }
Exemple #24
0
 public void AddPosition(Actor a, IOccupySpace ios)
 {
     UpdatePosition(a, ios);
 }
Exemple #25
0
		public void AddPosition(Actor a, IOccupySpace ios)
		{
			addActorPosition.Add(a);
		}
Exemple #26
0
 public void RemovePosition(Actor a, IOccupySpace ios)
 {
     removeActorPosition.Add(a);
 }
Exemple #27
0
		public void UpdatePosition(Actor a, IOccupySpace ios)
		{
			RemovePosition(a, ios);
			AddPosition(a, ios);
		}
Exemple #28
0
 public void AddPosition(Actor a, IOccupySpace ios)
 {
     addActorPosition.Add(a);
 }
Exemple #29
0
 public void Remove( Actor self, IOccupySpace unit )
 {
     if (unit != null)
         foreach (var c in unit.OccupiedCells())
             influence[c.X, c.Y].Remove(self);
 }
Exemple #30
0
 void INotifyCreated.Created(Actor self)
 {
     conditionManager = self.TraitOrDefault <ConditionManager>();
     positionable     = self.TraitOrDefault <IPositionable>();
     ios = self.TraitOrDefault <IOccupySpace>();
 }
Exemple #31
0
 public void RemoveInfluence(Actor self, IOccupySpace ios)
 {
     foreach (var c in ios.OccupiedCells())
         RemoveInfluenceInner(ref influence[c.First.X, c.First.Y], self);
 }
Exemple #32
0
		public void RemoveInfluence(Actor self, IOccupySpace ios)
		{
			foreach (var c in ios.OccupiedCells())
			{
				var temp = influence[c.First];
				RemoveInfluenceInner(ref temp, self);
				influence[c.First] = temp;
			}
		}
Exemple #33
0
 public void Add( Actor self, IOccupySpace unit )
 {
     foreach( var c in unit.OccupiedCells() )
         influence[c.X, c.Y].Add(self);
 }
Exemple #34
0
 public void RemoveFromMaps(Actor self, IOccupySpace ios)
 {
     ActorMap.RemoveInfluence(self, ios);
     ActorMap.RemovePosition(self, ios);
     ScreenMap.Remove(self);
 }
Exemple #35
0
 public void UpdatePosition(Actor a, IOccupySpace ios)
 {
     RemovePosition(a, ios);
     AddPosition(a, ios);
 }
Exemple #36
0
 public void Remove( Actor self, IOccupySpace unit )
 {
     if (unit != null)
         foreach (var c in unit.OccupiedCells())
             RemoveInner( ref influence[ c.First.X, c.First.Y ], self );
 }
Exemple #37
0
 public void Update(Actor self, IOccupySpace unit)
 {
     Remove(self, unit);
     if (!self.IsDead()) Add(self, unit);
 }
Exemple #38
0
 public void Add( Actor self, IOccupySpace unit )
 {
     if (unit != null)
         foreach( var c in unit.OccupiedCells() )
             influence[ c.First.X, c.First.Y ] = new InfluenceNode { next = influence[ c.First.X, c.First.Y ], subCell = c.Second, actor = self };
 }
Exemple #39
0
 public void AddPosition(Actor a, IOccupySpace ios)
 {
     UpdatePosition(a, ios);
 }
Exemple #40
0
        public void AddInfluence(Actor self, IOccupySpace ios)
        {
            foreach (var c in ios.OccupiedCells())
            {
                if (!map.Contains(c.First))
                    continue;

                influence[c.First] = new InfluenceNode { Next = influence[c.First], SubCell = c.Second, Actor = self };

                List<CellTrigger> triggers;
                if (cellTriggerInfluence.TryGetValue(c.First, out triggers))
                    foreach (var t in triggers)
                        t.Dirty = true;
            }
        }
Exemple #41
0
 public void UpdatePosition(Actor a, IOccupySpace ios)
 {
     RemovePosition(a, ios);
     addActorPosition.Add(a);
 }
Exemple #42
0
		public void AddInfluence(Actor self, IOccupySpace ios)
		{
			foreach (var c in ios.OccupiedCells())
				influence[c.First] = new InfluenceNode { Next = influence[c.First], SubCell = c.Second, Actor = self };
		}