/// <summary> /// Creates a deep copy of the system. The passed system must be of the same type. /// <para/> /// This clones any contained data types to return an instance that represents a complete copy of the one passed in. /// </summary> /// <param name="into">The instance to copy into.</param> public override void CopyInto(AbstractSystem into) { base.CopyInto(into); var copy = (CollisionAttributeEffectSystem)into; copy._newCollisions.Clear(); foreach (var info in _newCollisions) { copy._newCollisions.Add( info.Key, new NewCollisionInfo { Count = info.Value.Count, IsShieldA = info.Value.IsShieldA, IsShieldB = info.Value.IsShieldB, Normal = info.Value.Normal }); } copy._activeCollisions.Clear(); foreach (var collision in _activeCollisions) { copy._activeCollisions.Add( collision.Key, new ActiveCollisionInfo { Count = collision.Value.Count }); } }
/// <summary> /// Creates a deep copy of the system. The passed system must be of the same type. /// <para> /// This clones any contained data types to return an instance that represents a complete copy of the one passed /// in. /// </para> /// </summary> /// <remarks>The manager for the system to copy into must be set to the manager into which the system is being copied.</remarks> /// <returns>A deep copy, with a fully cloned state of this one.</returns> public override void CopyInto(AbstractSystem into) { base.CopyInto(into); var copy = (IndexSystem)into; foreach (var tree in copy._trees.Where(tree => tree != null)) { tree.Clear(); } foreach (var changed in copy._changed.Where(changed => changed != null)) { changed.Clear(); } for (var index = 0; index < _nextIndexId; ++index) { if (_trees[index] == null) { continue; } if (copy._trees[index] == null) { copy._trees[index] = _trees[index].NewInstance(); } if (copy._changed[index] == null) { copy._changed[index] = new HashSet <int>(); } _trees[index].CopyInto(copy._trees[index]); copy._changed[index].UnionWith(_changed[index]); } }
private void CreateSystemBind(Type type) { Console.WriteLine($"[ECS] Creating system instance of: {type.Name}"); AbstractSystem systemInstance = Activator.CreateInstance(type) as AbstractSystem; systems.Add(systemInstance); }
/// <summary>Removes the specified system from this manager.</summary> /// <param name="system">The system to remove.</param> /// <returns>Whether the system was successfully removed.</returns> public bool RemoveSystem(AbstractSystem system) { // Make sure we have a valid system. Debug.Assert(system != null); // Get type ID for that system. var systemTypeId = GetSystemTypeId(system.GetType()); // Check if we even have that system. if (_systemsByTypeId[systemTypeId] == null) { return(false); } // Unregister the system. _systems.Remove(system); while (systemTypeId != 0) { _systemsByTypeId[systemTypeId] = null; systemTypeId = SystemHierarchy[systemTypeId]; } system.Manager = null; foreach (var messageType in GetMessageCallbackTypes(system.GetType())) { RebuildMessageDispatcher(messageType); } return(true); }
/// <summary> /// Creates a deep copy of the system. The passed system must be of the same type. /// <para> /// This clones any contained data types to return an instance that represents a complete copy of the one passed /// in. /// </para> /// </summary> /// <param name="into">The instance to copy into.</param> public override void CopyInto(AbstractSystem into) { System.Diagnostics.Debug.Assert( _dropsToSample.Count == 0, "Drop system got drop requests after its update, but before copying."); base.CopyInto(into); }
/// <summary> /// Creates a deep copy of the system. The passed system must be of the same type. /// <para> /// This clones any contained data types to return an instance that represents a complete copy of the one passed /// in. /// </para> /// </summary> /// <param name="into">The instance to copy into.</param> public override void CopyInto(AbstractSystem into) { base.CopyInto(into); var copy = (DeathSystem)into; copy._entitiesToRemove.Clear(); copy._entitiesToRemove.UnionWith(_entitiesToRemove); }
/// <summary> /// Creates a deep copy of the system. The passed system must be of the same type. /// <para> /// This clones any contained data types to return an instance that represents a complete copy of the one passed /// in. /// </para> /// </summary> /// <remarks>The manager for the system to copy into must be set to the manager into which the system is being copied.</remarks> /// <returns>A deep copy, with a fully cloned state of this one.</returns> public override void CopyInto(AbstractSystem into) { base.CopyInto(into); var copy = (ShipSpawnSystem)into; copy._cellSpawns.Clear(); copy._cellSpawns.AddRange(_cellSpawns); }
public override void CopyInto(AbstractSystem into) { base.CopyInto(into); var copy = (EquipmentToFixtureSystem)into; copy._changedShape.Clear(); copy._changedShape.UnionWith(_changedShape); copy._changedMass.Clear(); copy._changedMass.UnionWith(_changedMass); }
/// <summary>Adds a copy of the specified system.</summary> /// <param name="system">The system to copy.</param> public void CopySystem(AbstractSystem system) { var systemTypeId = GetSystemTypeId(system.GetType()); if (_systemsByTypeId[systemTypeId] == null) { AddSystem(system.NewInstance()); } Debug.Assert(_systemsByTypeId[systemTypeId] != null); system.CopyInto(_systemsByTypeId[systemTypeId]); }
/// <summary> /// Creates a deep copy of the system. The passed system must be of the same type. /// <para> /// This clones any contained data types to return an instance that represents a complete copy of the one passed /// in. /// </para> /// </summary> /// <remarks>The manager for the system to copy into must be set to the manager into which the system is being copied.</remarks> /// <returns>A deep copy, with a fully cloned state of this one.</returns> public override void CopyInto(AbstractSystem into) { base.CopyInto(into); var copy = (UniverseSystem)into; copy._cellInfo.Clear(); foreach (var cellInfo in _cellInfo) { copy._cellInfo.Add(cellInfo.Key, cellInfo.Value.DeepCopy()); } }
public static void RunBacktest(this IMslScript script, AbstractSystem systemName) { var settings = new BackTestSettings(); settings.System = systemName; Interpreter.Context.Scope.Catalog.ForEach(() => { settings.TradedStock = Interpreter.Context.Scope.Stock.TradedStock; Interpreter.Context.ServiceProvider.TradingSC().DoBackTest(settings); }); }
/// <summary> /// Creates a deep copy of the system. The passed system must be of the same type. /// <para> /// This clones any contained data types to return an instance that represents a complete copy of the one passed /// in. /// </para> /// </summary> /// <remarks>The manager for the system to copy into must be set to the manager into which the system is being copied.</remarks> /// <returns>A deep copy, with a fully cloned state of this one.</returns> public override void CopyInto(AbstractSystem into) { base.CopyInto(into); var copy = (WeaponControlSystem)into; copy._cooldowns.Clear(); foreach (var item in _cooldowns) { copy._cooldowns.Add(item.Key, item.Value); } }
/// <summary> /// Creates a deep copy of the system. The passed system must be of the same type. /// <para> /// This clones any contained data types to return an instance that represents a complete copy of the one passed /// in. /// </para> /// </summary> /// <param name="into">The instance to copy into.</param> public override void CopyInto(AbstractSystem into) { base.CopyInto(into); var copy = (SquadSystem)into; foreach (var id in _squadIds) { copy._squads[id] = new SquadData { Formation = _squads[id].Formation, Spacing = _squads[id].Spacing, Cache = new FormationCache(_squads[id].Formation) }; copy._squads[id].Members.AddRange(_squads[id].Members); } }
public void Main(string arg) { if (me == null) { bool isMaster = TYPE_MASTER.Equals(arg, StringComparison.InvariantCultureIgnoreCase); if (isMaster) { me = new ShipFormationMaster(this); } else { me = new ShipFormationSlave(this); } Runtime.UpdateFrequency = UpdateFrequency.Update100; } else { me.Run(); } }
/// <summary> /// Creates a deep copy of the system. The passed system must be of the same type. /// <para> /// This clones any contained data types to return an instance that represents a complete copy of the one passed /// in. /// </para> /// </summary> /// <remarks>The manager for the system to copy into must be set to the manager into which the system is being copied.</remarks> /// <returns>A deep copy, with a fully cloned state of this one.</returns> public override void CopyInto(AbstractSystem into) { base.CopyInto(into); var copy = (CellSystem)into; copy._livingCells.Clear(); copy._livingCells.UnionWith(_livingCells); copy._pendingCells.Clear(); foreach (var item in _pendingCells) { copy._pendingCells.Add(item.Key, item.Value); } copy._livingSubCells.Clear(); copy._livingSubCells.UnionWith(_livingSubCells); copy._pendingSubCells.Clear(); foreach (var item in _pendingSubCells) { copy._pendingSubCells.Add(item.Key, item.Value); } }
/// <summary>Add the specified system to this manager.</summary> /// <param name="system">The system to add.</param> /// <returns>This manager, for chaining.</returns> public IManager AddSystem(AbstractSystem system) { // Get type ID for that system. var systemTypeId = GetSystemTypeId(system.GetType()); // Don't allow adding the same system twice. if (_systemsByTypeId[systemTypeId] != null) { throw new ArgumentException("You can not add more than one system of a single type."); } // Look for message callbacks in the system. This throws if a callback signature is invalid, // which is why we want to do this before registering the system. var messageTypes = GetMessageCallbackTypes(system.GetType()); // Add to general list, for serialization and hashing and general iteration. _systems.Add(system); // Register the system by type, for fast lookup. while (systemTypeId != 0) { _systemsByTypeId[systemTypeId] = system; systemTypeId = SystemHierarchy[systemTypeId]; } // Set the manager so that the system knows it belongs to us. system.Manager = this; // Rebuild message dispatchers for all changed types. foreach (var messageType in messageTypes) { RebuildMessageDispatcher(messageType); } // Tell the system it was added. system.OnAddedToManager(); return(this); }
/// <summary>Add the specified system to this manager.</summary> /// <param name="system">The system to add.</param> /// <returns>This manager, for chaining.</returns> public IManager AddSystem(AbstractSystem system) { if (_tss.CurrentFrame > 0) { throw new InvalidOperationException("Cannot add systems after simulation has started."); } if (system.GetType().IsDefined(typeof(PresentationOnlyAttribute), true)) { // Only insert in leading simulation. _tss.LeadingSimulation.Manager.AddSystem(system); } else { // Insert in all simulations. foreach (var state in _tss._simulations) { state.Manager.CopySystem(system); } } return(this); }
public virtual void Awake() { // If we already have one from the editor Inventory = AbstractSystem.CreateInstance <InventorySystem>(); }
public void AddSystem(AbstractSystem system) { this.systems.Add(system.GetType().Name, system); }
public void AddSystem(AbstractSystem system) { this.systems.Add(system.GetName(), system); }
/// <summary>Removes the specified system from this manager.</summary> /// <param name="system">The system to remove.</param> /// <returns>Whether the system was successfully removed.</returns> bool IManager.RemoveSystem(AbstractSystem system) { throw new NotSupportedException(); }
/// <summary>Adds a copy of the specified system.</summary> /// <param name="system">The system to copy.</param> void IManager.CopySystem(AbstractSystem system) { throw new NotSupportedException(); }