/// <summary> /// Copy Constructor -- don't call this directly, unless we never /// do ANY sub-classing. Instead use Clone(), which is more virtual. /// </summary> /// <param name="other"><see cref="Utility"/> being cloned.</param> private Utility(Utility other) { Type = other.Type; Name = other.Name; typeTags = new HashSet <string>(other.typeTags); description = other.description; Tint = other.Tint; deconstructInventory = other.deconstructInventory; Parameters = new Parameter(other.Parameters); Jobs = new BuildableJobs(this, other.Jobs); if (other.EventActions != null) { EventActions = other.EventActions.Clone(); } if (other.contextMenuLuaActions != null) { contextMenuLuaActions = new List <ContextMenuLuaAction>(other.contextMenuLuaActions); } getSpriteNameAction = other.getSpriteNameAction; tileTypeBuildPermissions = new HashSet <string>(other.tileTypeBuildPermissions); LocalizationCode = other.LocalizationCode; UnlocalizedDescription = other.UnlocalizedDescription; }
/// <summary> /// Copy Constructor -- don't call this directly, unless we never /// do ANY sub-classing. Instead use Clone(), which is more virtual. /// </summary> /// <param name="other"><see cref="Utility"/> being cloned.</param> private Utility(Utility other) { Type = other.Type; typeTags = new HashSet <string>(other.typeTags); Tint = other.Tint; // add cloned order actions orderActions = new Dictionary <string, OrderAction>(); foreach (var orderAction in other.orderActions) { orderActions.Add(orderAction.Key, orderAction.Value.Clone()); } Parameters = new Parameter(other.Parameters); Jobs = new BuildableJobs(this, other.Jobs); if (other.EventActions != null) { EventActions = other.EventActions.Clone(); } if (other.contextMenuLuaActions != null) { contextMenuLuaActions = new List <ContextMenuLuaAction>(other.contextMenuLuaActions); } getSpriteNameAction = other.getSpriteNameAction; tileTypeBuildPermissions = new HashSet <string>(other.tileTypeBuildPermissions); LocalizationName = other.LocalizationName; LocalizationDescription = other.LocalizationDescription; }
/// <summary> /// Copy Constructor -- don't call this directly, unless we never /// do ANY sub-classing. Instead use Clone(), which is more virtual. /// </summary> private Furniture(Furniture other) { Type = other.Type; Name = other.Name; typeTags = new HashSet <string>(other.typeTags); description = other.description; MovementCost = other.MovementCost; PathfindingModifier = other.PathfindingModifier; PathfindingWeight = other.PathfindingWeight; RoomEnclosure = other.RoomEnclosure; Width = other.Width; Height = other.Height; CanRotate = other.CanRotate; Rotation = other.Rotation; Tint = other.Tint; LinksToNeighbour = other.LinksToNeighbour; deconstructInventory = other.deconstructInventory; health = other.health; Parameters = new Parameter(other.Parameters); Jobs = new BuildableJobs(this, other.Jobs); // don't need to clone here, as all are prototype things (not changing) components = new HashSet <BuildableComponent>(); foreach (BuildableComponent component in other.components) { components.Add(component.Clone()); } if (other.Animation != null) { Animation = other.Animation.Clone(); } if (other.EventActions != null) { EventActions = other.EventActions.Clone(); } if (other.contextMenuLuaActions != null) { contextMenuLuaActions = new List <ContextMenuLuaAction>(other.contextMenuLuaActions); } isEnterableAction = other.isEnterableAction; getSpriteNameAction = other.getSpriteNameAction; getProgressInfoNameAction = other.getProgressInfoNameAction; tileTypeBuildPermissions = new HashSet <string>(other.tileTypeBuildPermissions); LocalizationCode = other.LocalizationCode; UnlocalizedDescription = other.UnlocalizedDescription; // force true as default, to trigger OnIsOperatingChange (to sync the furniture icons after initialization) IsOperating = true; }
/// <summary> /// Initializes a new instance of the <see cref="BuildableJobs"/> class by copying some of the values from another instance. /// </summary> /// <param name="buildEntity">The current buildable.</param> /// <param name="jobs">The buildable jobs to copy from.</param> public BuildableJobs(IBuildable buildEntity, BuildableJobs jobs) { buildable = buildEntity; activeJobs = new List <Job>(); pausedJobs = new List <Job>(); WorkSpotOffset = jobs.WorkSpotOffset; InputSpotOffset = jobs.InputSpotOffset; OutputSpotOffset = jobs.OutputSpotOffset; }
/// <summary> /// Copy Constructor -- don't call this directly, unless we never /// do ANY sub-classing. Instead use Clone(), which is more virtual. /// </summary> private Furniture(Furniture other) { Type = other.Type; Name = other.Name; typeTags = new HashSet <string>(other.typeTags); description = other.description; MovementCost = other.MovementCost; PathfindingModifier = other.PathfindingModifier; PathfindingWeight = other.PathfindingWeight; RoomEnclosure = other.RoomEnclosure; Width = other.Width; Height = other.Height; CanRotate = other.CanRotate; Rotation = other.Rotation; Tint = other.Tint; LinksToNeighbour = other.LinksToNeighbour; deconstructInventory = other.deconstructInventory; health = other.health; Parameters = new Parameter(other.Parameters); Jobs = new BuildableJobs(this, other.Jobs); // don't need to clone here, as all are prototype things (not changing) components = new HashSet <BuildableComponent>(other.components); if (other.Animation != null) { Animation = other.Animation.Clone(); } if (other.EventActions != null) { EventActions = other.EventActions.Clone(); } if (other.contextMenuLuaActions != null) { contextMenuLuaActions = new List <ContextMenuLuaAction>(other.contextMenuLuaActions); } isEnterableAction = other.isEnterableAction; getSpriteNameAction = other.getSpriteNameAction; getProgressInfoNameAction = other.getProgressInfoNameAction; if (other.PowerConnection != null) { PowerConnection = other.PowerConnection.Clone() as Connection; PowerConnection.NewThresholdReached += OnNewThresholdReached; } tileTypeBuildPermissions = new HashSet <string>(other.tileTypeBuildPermissions); LocalizationCode = other.LocalizationCode; UnlocalizedDescription = other.UnlocalizedDescription; }
/// TODO: Implement object rotation /// <summary> /// Initializes a new instance of the <see cref="Utility"/> class. /// </summary> public Utility() { Tint = new Color(1f, 1f, 1f, .25f); EventActions = new EventActions(); contextMenuLuaActions = new List <ContextMenuLuaAction>(); Parameters = new Parameter(); Jobs = new BuildableJobs(this); typeTags = new HashSet <string>(); tileTypeBuildPermissions = new HashSet <string>(); }
/// <summary> /// Initializes a new instance of the <see cref="Furniture"/> class. /// This constructor is used to create prototypes and should never be used ouside the Prototype Manager. /// </summary> public Furniture() { Tint = Color.white; VerticalDoor = false; EventActions = new EventActions(); contextMenuLuaActions = new List <ContextMenuLuaAction>(); Parameters = new Parameter(); Jobs = new BuildableJobs(this); typeTags = new HashSet <string>(); tileTypeBuildPermissions = new HashSet <string>(); PathfindingWeight = 1f; PathfindingModifier = 0f; Height = 1; Width = 1; CanRotate = false; Rotation = 0f; DragType = "single"; LinksToNeighbour = string.Empty; components = new HashSet <BuildableComponent>(); }
/// <summary> /// Copy Constructor -- don't call this directly, unless we never /// do ANY sub-classing. Instead use Clone(), which is more virtual. /// </summary> private Furniture(Furniture other) { Type = other.Type; typeTags = new HashSet <string>(other.typeTags); MovementCost = other.MovementCost; PathfindingModifier = other.PathfindingModifier; PathfindingWeight = other.PathfindingWeight; RoomEnclosure = other.RoomEnclosure; Width = other.Width; Height = other.Height; CanRotate = other.CanRotate; Rotation = other.Rotation; Tint = other.Tint; LinksToNeighbour = other.LinksToNeighbour; health = other.health; Parameters = new Parameter(other.Parameters); Jobs = new BuildableJobs(this, other.Jobs); // add cloned components components = new HashSet <BuildableComponent>(); foreach (BuildableComponent component in other.components) { components.Add(component.Clone()); } // add cloned order actions orderActions = new Dictionary <string, OrderAction>(); foreach (var orderAction in other.orderActions) { orderActions.Add(orderAction.Key, orderAction.Value.Clone()); } if (other.Animation != null) { Animation = other.Animation.Clone(); } if (other.EventActions != null) { EventActions = other.EventActions.Clone(); } if (other.contextMenuLuaActions != null) { contextMenuLuaActions = new List <ContextMenuLuaAction>(other.contextMenuLuaActions); } if (other.ReplaceableFurniture != null) { replaceableFurniture = other.ReplaceableFurniture; } isEnterableAction = other.isEnterableAction; getProgressInfoNameAction = other.getProgressInfoNameAction; tileTypeBuildPermissions = new HashSet <string>(other.tileTypeBuildPermissions); RequiresSlowUpdate = EventActions.HasEvent("OnUpdate") || components.Any(c => c.RequiresSlowUpdate); RequiresFastUpdate = EventActions.HasEvent("OnFastUpdate") || components.Any(c => c.RequiresFastUpdate); LocalizationCode = other.LocalizationCode; UnlocalizedDescription = other.UnlocalizedDescription; // force true as default, to trigger OnIsOperatingChange (to sync the furniture icons after initialization) IsOperating = true; }