// Constructors internal Session(Domain domain, SessionConfiguration configuration, bool activate) : base(domain) { Guid = Guid.NewGuid(); IsDebugEventLoggingEnabled = OrmLog.IsLogged(LogLevel.Debug); // Just to cache this value // Both Domain and Configuration are valid references here; // Configuration is already locked Configuration = configuration; Name = configuration.Name; identifier = Interlocked.Increment(ref lastUsedIdentifier); CommandTimeout = configuration.DefaultCommandTimeout; allowSwitching = configuration.Supports(SessionOptions.AllowSwitching); // Handlers Handlers = domain.Handlers; Handler = CreateSessionHandler(); // Caches, registry EntityStateCache = CreateSessionCache(configuration); EntityChangeRegistry = new EntityChangeRegistry(this); EntitySetChangeRegistry = new EntitySetChangeRegistry(this); ReferenceFieldsChangesRegistry = new ReferenceFieldsChangesRegistry(this); entitySetsWithInvalidState = new HashSet <EntitySetBase>(); // Events EntityEvents = new EntityEventBroker(); Events = new SessionEventAccessor(this, false); SystemEvents = new SessionEventAccessor(this, true); // Etc. PairSyncManager = new SyncManager(this); RemovalProcessor = new RemovalProcessor(this); pinner = new Pinner(this); Operations = new OperationRegistry(this); NonPairedReferencesRegistry = new NonPairedReferenceChangesRegistry(this); CommandProcessorContextProvider = new CommandProcessorContextProvider(this); // Validation context ValidationContext = Configuration.Supports(SessionOptions.ValidateEntities) ? (ValidationContext) new RealValidationContext() : new VoidValidationContext(); // Creating Services Services = CreateServices(); disposableSet = new DisposableSet(); remapper = new KeyRemapper(this); disableAutoSaveChanges = !configuration.Supports(SessionOptions.AutoSaveChanges); // Perform activation if (activate) { ActivateInternally(); } // Query endpoint SystemQuery = Query = new QueryEndpoint(new QueryProvider(this)); }
void SelectAbilities(AgentAI a) { string[] aNames; int[] aIds; a.GetAbilities().m_AbilityManager.GetAbilityNamesAndIDs(out aIds, out aNames); for (int i = 0; i < aIds.Length; i++) { if (a.GetAbilities() != null && a.GetAbilities().GetAbility(aIds[i]) != null) { try { if (a.GetAbilities().HasAbility(aIds[i])) { Ability abil = a.GetAbilities().GetAbility(aIds[i]); KeyCode keycode = KeyRemapper.GetMappingForAbility(aIds[i]).m_Key; switch (abil.State) { case Ability.AbilityState.prepped: Keyboard.Instance[keycode.ToKey()] = UnityEngine.Color.yellow.ToColore(); break; case Ability.AbilityState.activating: Keyboard.Instance[keycode.ToKey()] = UnityEngine.Color.gray.ToColore(); break; case Ability.AbilityState.active: Keyboard.Instance[keycode.ToKey()] = UnityEngine.Color.green.ToColore(); break; case Ability.AbilityState.ready: Keyboard.Instance[keycode.ToKey()] = UnityEngine.Color.white.ToColore(); break; default: Keyboard.Instance[keycode.ToKey()] = magenta; break; } if (abil.GetCooldownPercentage() > 0) { Keyboard.Instance[keycode.ToKey()] = a.IsSelected() ? UnityEngine.Color.yellow.ToColore() : magenta; } else if (abil.GetAmmoCount() == 0 && abil.GetMaxAmmo() != 0 && abil.GetCooldownPercentage() > 0) { Keyboard.Instance[keycode.ToKey()] = a.IsSelected() ? UnityEngine.Color.red.ToColore() : magenta; } } } catch { } } } }
void DeselectAbilities(AgentAI a) { string[] aNames; int[] aIds; a.GetAbilities().m_AbilityManager.GetAbilityNamesAndIDs(out aIds, out aNames); for (int i = 0; i < aIds.Length; i++) { if (a.GetAbilities() != null && a.GetAbilities().GetAbility(aIds[i]) != null) { try { if (a.GetAbilities().HasAbility(aIds[i])) { Ability abil = a.GetAbilities().GetAbility(aIds[i]); KeyCode keycode = KeyRemapper.GetMappingForAbility(aIds[i]).m_Key; Keyboard.Instance[keycode.ToKey()] = magenta; } } catch { } } } }