/// <summary> /// Shut down the Academy. /// </summary> public void Dispose() { DisableAutomaticStepping(); // Signal to listeners that the academy is being destroyed now DestroyAction?.Invoke(); Communicator?.Dispose(); Communicator = null; if (m_ModelRunners != null) { foreach (var mr in m_ModelRunners) { mr.Dispose(); } m_ModelRunners = null; } // Clear out the actions so we're not keeping references to any old objects ResetActions(); // TODO - Pass worker ID or some other identifier, // so that multiple envs won't overwrite each others stats. TimerStack.Instance.SaveJsonTimers(); FloatProperties = null; m_Initialized = false; // Reset the Lazy instance s_Lazy = new Lazy <Academy>(() => new Academy()); }
protected virtual void ProcessDestroyAction(DestroyAction action, List <StackResponseContainerInfo> stackResponses) { byte count = action.Count; StackRequestSlotInfo source = action.Source; Item sourceItem = GetContainerItem(source.ContainerId, source.Slot); sourceItem.Count -= count; if (sourceItem.Count <= 0) { sourceItem = new ItemAir(); SetContainerItem(source.ContainerId, source.Slot, sourceItem); } stackResponses.Add(new StackResponseContainerInfo { ContainerId = source.ContainerId, Slots = new List <StackResponseSlotInfo> { new StackResponseSlotInfo() { Count = sourceItem.Count, Slot = source.Slot, HotbarSlot = source.Slot, StackNetworkId = sourceItem.UniqueId } } }); }
/// <summary> /// Deinitialized this SceneObject and all its hierarchical decendants. /// </summary> public void Destroy() { if (IsUpdateable) { SceneManager.RemoveUpdateReceiver(Update, Render, Root); } DestroyAction?.Invoke(); var children = new List <Transform>(Transform.Children); foreach (var t in children) { t.Owner.Destroy(); } var components = new List <UIComponent>(Components); components.ForEach(x => x.Destroy()); if (Parent != null) { Parent.Transform.Children.Remove(Transform); } }
private static bool ResolveDestroy(DestroyAction action, EncounterState state) { Entity entity = state.GetEntityById(action.ActorId); var onDeathComponent = entity.GetComponent <OnDeathComponent>(); // this 'shouldRemoveEntity' code is slightly confusing, simplify it if you come back to it bool shouldRemoveEntity = true; if (onDeathComponent != null) { foreach (var effectType in onDeathComponent.ActiveEffectTypes) { var effectStopsRemoval = !ResolveOnDeathEffect(effectType, state); if (effectStopsRemoval) { shouldRemoveEntity = false; } } } if (shouldRemoveEntity) { state.RemoveEntity(entity); return(true); } else { return(false); } }
public static async Task Exec(GameScene scene, Sprite[,] sprites, DestroyAction act, Tween tween, Node2D animTemplate) { await new DestroyAct(scene, sprites, act, tween, animTemplate).Exec(); }
internal static void AddDestroyAction(Action destroyAction) { var action = new DestroyAction { Action = destroyAction }; _destroyActions.Add(action); }
/// <summary> /// Removes this UIComponent from its parent and unregisters it as UpdateReceiver. Invokes function OnDestroy. /// </summary> public void Destroy() { Owner.Components.Remove(this); if (IsUpdateable) { SceneManager.RemoveUpdateReceiver(Update, Render, Root); } DestroyAction?.Invoke(); }
/// <summary> /// Cleanup function /// </summary> protected void OnDestroy() { // Signal to listeners that the academy is being destroyed now DestroyAction?.Invoke(); foreach (var mr in m_ModelRunners) { mr.Dispose(); } // TODO - Pass worker ID or some other identifier, // so that multiple envs won't overwrite each others stats. TimerStack.Instance.SaveJsonTimers(); }
public DamageableConfig(DamageableConfig copyFrom) { health = copyFrom.health; points = copyFrom.points; isPlayer = copyFrom.isPlayer; destructible = copyFrom.destructible; registerAsTarget = copyFrom.registerAsTarget; triggerVariable = copyFrom.triggerVariable; allowMelee = copyFrom.allowMelee; hideWhenDestroyed = copyFrom.hideWhenDestroyed; stateChange = copyFrom.stateChange; destroyAction = copyFrom.destroyAction; endValue = copyFrom.endValue; duration = copyFrom.duration; breakSounds = copyFrom.breakSounds; }
/// <summary> /// Cleanup function /// </summary> protected virtual void OnDestroy() { Physics.gravity = m_OriginalGravity; Time.fixedDeltaTime = m_OriginalFixedDeltaTime; Time.maximumDeltaTime = m_OriginalMaximumDeltaTime; // Signal to listeners that the academy is being destroyed now DestroyAction?.Invoke(); foreach (var mr in m_ModelRunners) { mr.Dispose(); } // TODO - Pass worker ID or some other identifier, // so that multiple envs won't overwrite each others stats. TimerStack.Instance.SaveJsonTimers(); }
private DestroyAct(GameScene scene, Sprite[,] itemSprites, DestroyAction act, Tween tween, Node2D animTemplate) { _scene = scene; _sprites = itemSprites; _act = act; _tween = tween; _animTemplate = animTemplate; // _destroyedBy = new Dictionary <Sprite, ItemPos>(); foreach (ItemPos dPos in _act.DestroyedBy.Values.SelectMany(p => p)) { _destroyedBy[_sprites[dPos.Pos.X, dPos.Pos.Y]] = dPos; } }
private static bool ResolveOnDeathEffect(DestroyAction action, string effectType, EncounterState state) { if (effectType == OnDeathEffectType.PLAYER_VICTORY) { state.NotifyPlayerVictory(); return(true); } else if (effectType == OnDeathEffectType.PLAYER_DEFEAT) { state.NotifyPlayerDefeat(); return(true); } else if (effectType == OnDeathEffectType.REMOVE_FROM_UNIT) { var unit = state.GetUnit(state.GetEntityById(action.ActorId).GetComponent <UnitComponent>().UnitId); unit.NotifyEntityDestroyed(state.GetEntityById(action.ActorId)); return(false); } else { throw new NotImplementedException(String.Format("Don't know how to resolve on death effect type {0}", effectType)); } }