private void CommonComponent_Closing(object sender, EventArgs e) { CommonComponents.Remove(sender as IComponent); Form componentForm = sender as Form; if (componentForm != null) { componentForm.FormClosing -= this.CommonComponent_Closing; componentForm.Close(); } (sender as IDisposable)?.Dispose(); }
private void Awake() { m_CurrentState = ScriptableObject.CreateInstance(typeof(Uninitalized)) as Uninitalized; m_CurrentState.EntityStateMachine = this; CommonComponents commonComponents = new CommonComponents(); commonComponents.EntityController = gameObject.GetComponent <EntityController>(); commonComponents.EnemyController = commonComponents.EntityController as EnemyController; commonComponents.AttackController = commonComponents.EntityController as IAttackController; commonComponents.RotationalController = commonComponents.EntityController as IRotationalController; commonComponents.TranslationalController = commonComponents.EntityController as ITranslationalController; commonComponents.MuzzleComponentController = commonComponents.EntityController as IMuzzleComponentController; GameObjectComponents = commonComponents; }
public async Task Exit(bool immediately = false) { if (this.IsInitialized && !immediately) { await DisposeWorkplace(true); } foreach (IComponent commonComponent in CommonComponents.Where(c => c is IDisposable)) { (commonComponent as IDisposable)?.Dispose(); } Application.Exit(); }
public IComponent NewCommonComponent(ComponentTypeInfo commonComponentType) { IComponent newCommon = ComponentBuildersService.CommonBuilder.GetNew(commonComponentType); Form newCommonForm = newCommon as Form; if (newCommonForm != null) { newCommonForm.MdiParent = MainForm as Form; newCommonForm.FormClosing += this.CommonComponent_Closing; } CommonComponents.Add(newCommon); return(newCommon); }
public void Initialize(ref CommonComponents.SimulationModelTools.SimulationModelInfo simModel, ref CommonComponents.SimulationObjectTools.Blackboard blackboard, ref CommonComponents.SimulationEventTools.SimulationEventDistributor distributor) { IndividualDMIsLoggedIn = false; this.blackboard = blackboard; this.bbClient = new BlackboardClient(); this.distributor = distributor; this.distClient = new SimulationEventDistributorClient(); this.simModel = simModel; scoreRulesExist = new Dictionary<string, bool>(); handledAttacks = new List<string>(); classifications = new Dictionary<string, string>(); _terminalToDMMap = new Dictionary<string, string>(); dms = new List<string>(); objectAssignmentList = new Dictionary<string, string>(); mostRecentItemsForStimulators = new Dictionary<string,ItemInfo>(); _attackTargetHashes = new List<string>(); dms.Add("BAMS DM"); dms.Add("Firescout DM"); dms.Add("Individual DM"); distributor.RegisterClient(ref distClient); blackboard.RegisterClient(ref bbClient); //only need to register for attributes we're concerned with: ID, OwnerID, Location, DefaultClassification bbClient.Subscribe("PhysicalObject", "ID", true, false); bbClient.Subscribe("PhysicalObject", "Location", true, false); bbClient.Subscribe("PhysicalObject", "OwnerID", true, false); bbClient.Subscribe("PhysicalObject", "State", true, false); bbClient.Subscribe("PhysicalObject", "ClassName", true, false); bbClient.Subscribe("PhysicalObject", "DefaultClassification", true, false); bbClient.Subscribe("PhysicalObject", "CurrentClassification", true, false); //this might not be sent to simulators, only DDD Clients bbClient.Subscribe("PhysicalObject", "InActiveRegions", true, false); bbClient.Subscribe("PhysicalObject", "DestinationLocation", true, false); bbClient.Subscribe("PhysicalObject", "Intent", true, true); #region Attributes Specifically For SEAMATE bbClient.Subscribe("PhysicalObject", "RevealTime", true, true); //int bbClient.Subscribe("PhysicalObject", "DetectTime", true, true); //int bbClient.Subscribe("PhysicalObject", "IdentifyTime", true, true); //int bbClient.Subscribe("PhysicalObject", "TrackingTime", true, true); //int, not sure how this will be changed yet. bbClient.Subscribe("PhysicalObject", "DestroyedTime", true, true); //int bbClient.Subscribe("PhysicalObject", "TrackedBy", true, true); bbClient.Subscribe("PhysicalObject", "DestroyedBy", true, true); bbClient.Subscribe("PhysicalObject", "IdentifiedBy", true, true); bbClient.Subscribe("PhysicalObject", "ClassifiedBy", true, true); bbClient.Subscribe("PhysicalObject", "DetectedBy", true, true); /* * GroundTruthIFF is either "Hostile", "Unknown", or "Friendly". On reveal, everything should be set to Unknown. * If this object attacks any sea vessel, it should be set to "Hostile". * UserClassifiedIFF is either "Hostile", "Unknown", or "Friendly", and is set when a user classifies an object. * This is their PERCEIVED friendliness of an object. */ bbClient.Subscribe("PhysicalObject", "GroundTruthIFF", true, true); //string bbClient.Subscribe("PhysicalObject", "UserClassifiedIFF", true, true); //string bbClient.Subscribe("PhysicalObject", "HostileActionTime", true, true); //int bbClient.Subscribe("PhysicalObject", "IsInSeaLane", true, true); //bool bbClient.Subscribe("PhysicalObject", "IsGoingTowardsPort", true, true); //bool #endregion objectProxies = new Dictionary<string, SimulationObjectProxy>(); }
public void ProcessEvent(CommonComponents.SimulationEventTools.SimulationEvent e) { Console.Out.WriteLine("in processevent with eventType: " + e.eventType); switch (e.eventType) { case "NewObject": NewObject(e); break; case "TimeTick": TimeTick(e); break; case "RevealObject": RevealObject(e); break; case "AttackObject": AttackObject(e); break; case "ExternalApp_SimStop": ResetSimulation(); break; case "ForceUpdateObjectAttribute": ForceUpdateObjectAttribute(e); break; case "ClientMeasure_ObjectSelected": ClickHandler(e); break; case "ObjectClassificationRequest": ClassificationChanged(e); break; case "AttackSucceeded": AttackSucceeded(e); break; case "SEAMATE_TrackAdded": Console.Out.WriteLine("----------------SEAMATE_TrackAdded"); TrackAdded(e); break; case "SEAMATE_TrackRemoved": Console.Out.WriteLine("----------------SEAMATE_TrackRemoved"); TrackRemoved(e); break; //case "AuthenticationRequest": //case "AuthenticationResponse": //case "HandshakeGUIRegister": //case "HandshakeGUIRoleRequest": case "HandshakeInitializeGUI": String playerID = ((StringValue)e["PlayerID"]).value; if (playerID == "AgentDM") return; String terminalID = ((StringValue)e["TerminalID"]).value; if (_terminalToDMMap.ContainsKey(terminalID)) { _terminalToDMMap[terminalID] = playerID; } else { _terminalToDMMap.Add(terminalID, playerID); } if (playerID.ToLower().StartsWith("individual")) { IndividualDMIsLoggedIn = true; } break; case "SEAMATE_RequestMyDecisionMaker": String compName = ((StringValue)e["ComputerName"]).value; String terminal = ((StringValue)e["TerminalID"]).value; foreach (String s in _terminalToDMMap.Keys) { if (s.StartsWith(compName)) { SendDecisionMakerResponseEvent(terminal, _terminalToDMMap[s]); break; } } SendDecisionMakerResponseEvent(terminal, ""); break; case "SEAMATE_StimulusSent": StimulusItem(e); break; case "SelfDefenseAttackStarted": SelfDefenseAttackStarted(e); break; default: break; } }