public void ChangeObjectLocation(ObjectComponent component, short tileX, short tileY, sbyte level) { /** It has never been placed before if tileX == -2 **/ if (component.TileX != -2) { var currentOffset = GetOffset(tileX, tileY); var currentList = Objects[currentOffset]; if (currentList != null) { currentList.RemoveObject(component); } } var newOffset = GetOffset(tileX, tileY); var newList = Objects[newOffset]; if (newList == null) { newList = Objects[newOffset] = new BlueprintObjectList(); } newList.AddObject(component); component.blueprint = this; component.TileX = tileX; component.TileY = tileY; component.Level = level; component.Position = new Microsoft.Xna.Framework.Vector3(tileX, tileY, 0); if (!All.Contains(component)) { All.Add(component); } Damage.Add(new BlueprintDamage(BlueprintDamageType.OBJECT_MOVE, tileX, tileY, level) { Component = component }); OccupiedTilesDirty = true; }
public void ChangeObjectLocation(ObjectComponent component, short tileX, short tileY, sbyte level) { /** It has never been placed before if tileX == -2 **/ if (component.TileX != -2){ var currentOffset = GetOffset(tileX, tileY); var currentList = Objects[currentOffset]; if (currentList != null){ currentList.RemoveObject(component); } } var newOffset = GetOffset(tileX, tileY); var newList = Objects[newOffset]; if (newList == null){ newList = Objects[newOffset] = new BlueprintObjectList(); } newList.AddObject(component); component.blueprint = this; component.TileX = tileX; component.TileY = tileY; component.Level = level; component.Position = new Microsoft.Xna.Framework.Vector3(tileX, tileY, 0); if (!All.Contains(component)) { All.Add(component); } Damage.Add(new BlueprintDamage(BlueprintDamageType.OBJECT_MOVE, tileX, tileY, level) { Component = component }); OccupiedTilesDirty = true; }
public void ChangeObjectLocation(ObjectComponent component, LotTilePos pos) { short tileX = (pos.x < 0) ? (short)0 : pos.TileX; short tileY = (pos.y < 0) ? (short)0 : pos.TileY; sbyte level = pos.Level; /** It has never been placed before if tileX == -2 **/ if (component.TileX != -2){ var currentOffset = GetOffset(component.TileX, component.TileY); var currentList = Objects[currentOffset]; if (currentList != null){ currentList.RemoveObject(component); } } if (tileX != -2) { var newOffset = GetOffset(tileX, tileY); var newList = Objects[newOffset]; if (newList == null) { newList = Objects[newOffset] = new BlueprintObjectList(); } newList.AddObject(component); if (!All.Contains(component)) { All.Add(component); } } else if (All.Contains(component)) { All.Remove(component); } Damage.Add(new BlueprintDamage(BlueprintDamageType.OBJECT_MOVE, tileX, tileY, level) { Component = component }); OccupiedTilesDirty = true; component.blueprint = this; component.TileX = tileX; component.TileY = tileY; component.Level = level; component.Position = new Microsoft.Xna.Framework.Vector3(pos.x / 16.0f, pos.y / 16.0f, (level - 1) * 3.0f); }