private void InitBehaviourTree() { _behaviourManagerComponent = GetComponent <BehaviourManager>(); EnemyBehaviourTree.Root = new BehaviourRootNode(); EnemyBehaviourTree.WaitForTurn = new BehaviourWaitForCondition(IsEnemyTurn, 1f, 0f); EnemyBehaviourTree.Root.AddChild(EnemyBehaviourTree.WaitForTurn); EnemyBehaviourTree.SequencePlayTurn = new BehaviourSequence(false); EnemyBehaviourTree.SequencePlayTurn.Name = "Play Turn"; EnemyBehaviourTree.WaitForTurn.AddChild(EnemyBehaviourTree.SequencePlayTurn); EnemyBehaviourTree.ActionDoAnnounceAction = new BehaviourAction(DoAnnounceAction, "Do Announce Attack"); EnemyBehaviourTree.SequencePlayTurn.AddChild(EnemyBehaviourTree.ActionDoAnnounceAction); EnemyBehaviourTree.WaitBeforeAction = new BehaviourWait(1f); EnemyBehaviourTree.SequencePlayTurn.AddChild(EnemyBehaviourTree.WaitBeforeAction); EnemyBehaviourTree.SelectorDecideAction = new BehaviourSelector(false); EnemyBehaviourTree.ActionDoHeal = new BehaviourAction(DoHeal, "Do Heal"); EnemyBehaviourTree.ActionDoHeal.OnStarted.AddListener(DoHealOnStarted_Listener); EnemyBehaviourTree.ConditionShouldHeal = new BehaviourCondition(ShouldEnemyHeal, EnemyBehaviourTree.ActionDoHeal); EnemyBehaviourTree.ConditionShouldHeal.Name = "Should Heal"; EnemyBehaviourTree.SelectorDecideAction.AddChild(EnemyBehaviourTree.ConditionShouldHeal); EnemyBehaviourTree.ActionDoAttack = new BehaviourAction(DoAttack, "Do Attack"); EnemyBehaviourTree.ActionDoAttack.OnStarted.AddListener(DoAttackOnStarted_Listener); EnemyBehaviourTree.SelectorDecideAction.AddChild(EnemyBehaviourTree.ActionDoAttack); EnemyBehaviourTree.SequencePlayTurn.AddChild(EnemyBehaviourTree.SelectorDecideAction); _behaviourManagerComponent.SetCurrentTree(EnemyBehaviourTree.Root, true); }
protected void InitComponents() { _botGroundComponent = GetComponent <BotGround>(); _behaviourManagerComponent = GetComponent <BehaviourManager>(); _botVisionComponent = GetComponent <BotPartVision>(); FlagHolder = gameObject.GetChild(NAME_FLAGHOLDER); }
// it is assumed the current projectile is a generic projectile with an empty reference behaviour to fill up public void Clone(Projectile p_projectile, ProjectileInfo p_projectileInfo, List <ProjectileBehaviour> p_extraBehaviours) { p_projectile.LoadComponents(); LoadComponents(); SpriteRenderer render = m_render; BoxCollider2D collider = m_boxCollider; render.sprite = p_projectile.m_render.sprite; collider.size = p_projectile.m_boxCollider.size; collider.offset = p_projectile.m_boxCollider.offset; // this will overwrite any assignment done to this projectile beforehand p_projectile.Copy(typeof(Projectile), gameObject); m_render = render; m_boxCollider = collider; m_info = p_projectileInfo; m_behaviourManager = GetComponent <BehaviourManager>(); m_behaviourManager.m_behaviours = new Dictionary <ProjectileBehaviour, bool>(); foreach (ProjectileBehaviour behaviour in m_info.m_behaviours) { m_behaviourManager.m_behaviours.Add(behaviour, false); } foreach (ProjectileBehaviour behaviour in p_extraBehaviours) { m_behaviourManager.m_behaviours.Add(behaviour, false); } m_original = p_projectile; }
public override void UpdateBehaviour(BehaviourManager manager) { if (checkBehaviour(manager)) { manager.behaviours.Pop(); } }
public void InitializeServices(ContentManager c, SpriteBatch sb) { MouseHandler mouseHandle = new MouseHandler(); registerUPDService <MouseHandler>(mouseHandle); KeyHandler keyHandle = new KeyHandler(); registerUPDService <KeyHandler>(keyHandle); //////////////////////////////////////////////////////////////////////// CameraManager camManage = new CameraManager(); camManage.Initialize(); registerUPDService <CameraManager>(camManage); SoundManager soundManage = new SoundManager(); registerService <SoundManager>(soundManage); IResourceLoader resource = new ResourceLoader(); resource.Content = c; resource.Initialize(); registerService <IResourceLoader>(resource); EntityManager entityManage = new EntityManager(); registerService <EntityManager>(entityManage); BehaviourManager behaveManage = new BehaviourManager(); registerUPDService <BehaviourManager>(behaveManage); DetectionManger detectManage = new DetectionManger(); registerUPDService <DetectionManger>(detectManage); RenderManager render = new RenderManager(); registerUPDService <RenderManager>(render); IScreenManager screenManage = new ScreenManager(); screenManage.Initialize(); registerService <IScreenManager>(screenManage); soundManage.Initialize(); registerUPDService <IScreenManager>(screenManage); }
private void UnregisterUpdateable() { BehaviourManager manager = BehaviourManager.Instance; if (manager != null) { manager.Remove(this); } else { Debug.LogError("Behaviour Manager not present!"); } }
public bool pathComplete(BehaviourManager manager) { if (!manager.agent.pathPending) { if (manager.agent.stoppingDistance >= manager.agent.remainingDistance) { if (!manager.agent.hasPath || manager.agent.velocity.sqrMagnitude == 0f) { return(true); } } } return(false); }
public static void Initialize() { settings = new KZ_Settings(); devConsole = DevConsole.Create(); devConsole.Initialize(); behaviourManager = BehaviourManager.Create(); behaviourManager.Initialize(); appFlow = AppFlow.Create(); appFlow.Inititalize(); Debug.Log("locator initialized"); }
// execute current behaviour and check if we need to change it // also update the mood, currently uses the first mood, but in the future if you have multiple people detected you can make it follow a certain person by assigning said person an id private void Behaviour() { var moods = Instances.GetEmotions(); if (moods.Count != 0) { _mood = moods[0]; if (_nextBehaviour) { _previousBehaviourChange = DateTime.Now; _behaviour = BehaviourManager.GetBehaviour(_mood); _nextBehaviour = false; } } _nextBehaviour = _behaviour.Execute(this); }
public MonsterAI(Monster _monster) { monster = _monster; aiInfo = monster.aiInfo; anim = monster.gameObject.AddComponent <Animator> (); anim.runtimeAnimatorController = GameObject.Instantiate <RuntimeAnimatorController> (Resources.Load("AI/BaseAI") as RuntimeAnimatorController); behaviourManager = new BehaviourManager(anim, this); //Create dictionary of state names from state machines with the functions they will call, names must match stateNames above stateDict = new Dictionary <string, BaseState>(); stateDict.Add("Idle", new IdleState(monster)); stateDict.Add("Die", new DieState(monster)); stateDict.Add("AttackTarget", new AttackState(monster)); stateDict.Add("Enraged", new EnragedState(monster)); stateDict.Add("ChaseTarget", new ChaseState(monster)); stateDict.Add("Wander", new WanderState(monster)); stateDict.Add("Retreat", new RetreatState(monster)); }
// Use this for initialization public virtual void Start() { GameObject gameMngr = GameObject.Find("GameManager"); if (null == gameMngr) { Debug.Log("Error in " + gameObject.name + ": Requires a GameManager object in the scene."); Debug.Break(); } position = transform.position; behaviourMngr = gameMngr.GetComponent <BehaviourManager>(); worldSize = behaviourMngr.worldSize; //Check that mas is initialized to something. Mass cannot be negative if (mass <= 0.0f) { mass = 0.01f; } }
public void InitUnit(EnumInfo.TeamType _tType) { _tr = transform; _unitData = DataManager.Instance.GetUnitDataWithUnitIdx(_unitIdx); _teamType = _tType; _stateMgr = GetComponentInChildren <StateManager>(); _animMgr = GetComponentInChildren <AnimManager>(); _behaviourMgr = GetComponentInChildren <BehaviourManager>(); _moveMgr = GetComponentInChildren <MoveManager>(); _seeker = GetComponentInChildren <Seeker>(); _stateMgr.InitStateMgr(this); _animMgr.InitAnimMgr(this); _behaviourMgr.InitBehaviourMgr(this); _moveMgr.InitMoveMgr(this); if (_unitData.DamageType.Equals("Physic")) { _normalDamage.Type = EnumInfo.DamageType.Physic; } else { _normalDamage.Type = EnumInfo.DamageType.Magic; } _normalDamage.DamagePower = _unitData.Damage; _normalDamage.ResourceUnit = this; if (_unitData.SkillDamageType.Equals("Physic")) { _skillDamage.Type = EnumInfo.DamageType.Physic; } else { _skillDamage.Type = EnumInfo.DamageType.Magic; } _skillDamage.DamagePower = _unitData.SkillDamage; _skillDamage.ResourceUnit = this; }
private void GetGenerators() { BehaviourManager.OnFinishedInitializing -= GetGenerators; _generators = new Dictionary <Type, CustomIDGeneratorAttribute>(); foreach (CustomIDGeneratorAttribute generator in BehaviourManager.GetBehaviours <CustomIDGeneratorAttribute>()) { if (_generators.ContainsKey(generator.Type)) { if (_generators[generator.Type].Priority < generator.Priority) { _generators[generator.Type] = generator; } } else { _generators.Add(generator.Type, generator); } } }
// Use this for initialization void Start() { maxSpeed = UnityEngine.Random.Range(0.01f, 0.08f); townhall = GameObject.Find("GameManager").GetComponent <TileManager>().Tiles[GameObject.Find("GameManager").GetComponent <TileManager>().numrows][GameObject.Find("GameManager").GetComponent <TileManager>().numcolumns].GetComponent <Tile>().Buildingattached; gameMngr = GameObject.Find("GameManager"); if (null == gameMngr) { Debug.Log("Error in " + gameObject.name + ": Requires a GameManager object in the scene."); Debug.Break(); } position = transform.position; behaviourMngr = gameMngr.GetComponent <BehaviourManager>(); //Check that mas is initialized to something. Mass cannot be negative if (mass <= 0.0f) { mass = 0.01f; } target = townhall; }
public static void Initialize() { if (HasInitialized) { return; } HasInitialized = true; HierarchyManager.Initialize(); HookUpJSONReferenceHandler(); OnSerializationStarted?.Invoke(); AssemblyManager.Initialize(); IDManager.Initialize(); Converter.Initialize(); BlockedTypes.Initialize(); BehaviourManager.Initialize(); AssemblyManager.ExecuteReflection(); }
public static IEnumerator Initialize(MonoBehaviour mono, KernelInitializeData initializeData) { MDebug.Assert(ms_IsInitialized == false, "ms_IsInitialized == false"); ms_IsInitialized = true; Mono = mono; MDebug.Log("Core", "Initialize kernel with date:\n" + JsonUtility.ToJson(initializeData, true)); BehaviourManager = new GameObject("GF.Core").AddComponent <BehaviourManager>(); yield return(null); ObjectPool = new ObjectPoolManager(initializeData); yield return(null); // add gf event if (initializeData.EventTypes == null) { initializeData.EventTypes = new List <Type>(); } initializeData.EventTypes.Insert(0, typeof(EventName)); EventCenter = new EventCenter(initializeData); yield return(null); EntityManager = new EntityManager(initializeData); yield return(null); DownloadManager = new TempDownloadManager(); yield return(DownloadManager.InitializeAsync(initializeData)); if (initializeData.UseAssetBundle) { AssetManager = new AssetManager(); yield return(((AssetManager)AssetManager).InitializeAsync(initializeData)); } //TempAssetInitManager AssetInitManager = new TempAssetInitManager(); yield return(AssetInitManager.InitializeAsync(initializeData)); #if UNITY_EDITOR UiManager = new EditorFairyGUIWindowManager(); #else UiManager = new FairyGUIWindowManager(); #endif yield return(null); #region Initialize Packages List <Common.Utility.ReflectionUtility.MethodAndAttributeData> initializePackages = new List <Common.Utility.ReflectionUtility.MethodAndAttributeData>(); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int iAssembly = 0; iAssembly < assemblies.Length; iAssembly++) { Common.Utility.ReflectionUtility.CollectionMethodWithAttribute(initializePackages , assemblies[iAssembly] , BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public , typeof(InitializePackageAttribute) , false); } List <InitializePackageData> initializePackageDatas = new List <InitializePackageData>(); for (int iPackage = 0; iPackage < initializePackages.Count; iPackage++) { initializePackageDatas.Add(new InitializePackageData(initializePackages[iPackage])); } initializePackageDatas.Sort(InitializePackageData.ComparerByPriority); yield return(null); object[] initializePackageParameters = new object[] { initializeData }; for (int iPackage = 0; iPackage < initializePackageDatas.Count; iPackage++) { InitializePackageData iterPackageData = initializePackageDatas[iPackage]; MDebug.Log("Core" , $"Begin initialize package {iterPackageData.Name}"); object result = iterPackageData.Method.Invoke(null, initializePackageParameters); if (result != null && result is IEnumerator enumerator) { yield return(enumerator); } MDebug.Log("Core" , $"End initialize package {iterPackageData.Name}"); yield return(null); } #endregion }
public virtual void UpdateBehaviour(BehaviourManager manager) { }
public virtual bool checkBehaviour(BehaviourManager manager) { return(false); }
public void Initialize(BehaviourManager _manager) { manager = _manager; mahHash = GetHashCode(); string s = "shalom"; }
private void CreateChart() { chartPanel.Children.Remove(CurrentChart); CurrentChart = new Chart(); chartPanel.Children.Add(CurrentChart); CurrentChart.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; CurrentChart.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; CurrentChart.LegendVisibility = System.Windows.Visibility.Collapsed; XAxesForamtString = Answer.Properties.XValueFormatString; XAxesType = Answer.Properties.XAxisType; chartPanel.Children.Remove(SettingsPanel); chartPanel.Children.Add(SettingsPanel); BehaviourManager manager=new BehaviourManager(); manager.AllowMultipleEnabled = true; manager.IsEnabled = true; TrackballBehaviour track=new TrackballBehaviour(); manager.Behaviours.Add(track); track.IsEnabled = true; track.TrackingMode = TrackingPointPattern.LineOnX; track.HideTrackballsOnMouseLeave = true; ZoomBehaviour zoom=new ZoomBehaviour(); zoom.AnimationEnabled = false; zoom.ZoomMode = ZoomMode.MouseDrag; zoom.DisableAxisRendering = true; manager.Behaviours.Add(zoom); zoom.IsEnabled = true; TrackBehaviour = track; CurrentChart.LegendVisibility = Visibility.Collapsed; CurrentChart.Behaviour = manager; }
private void Init() { behaviourManager = new BehaviourManager(); inputManager = new InputManager(behaviourManager); }
public override void doBehaviour(BehaviourManager manager) { manager.agent.destination = target.transform.position; }
public override bool checkBehaviour(BehaviourManager manager) { return(pathComplete(manager)); return(false); }
protected DynamicObject() { Behaviours = new BehaviourManager(); _AnimatedProperties = new List<IPropertyAnimator>(); BlendState = BlendState.AlphaBlend; }
public virtual void doBehaviour(BehaviourManager manager) { }
public UnitManager(LevelScreen screen) { this.screen = screen; behaviours = new BehaviourManager(); Settings unitSettings = null; { unitSettings = new Settings { Health = 100, Damage = 30, AttackInterval = 0.1f, Speed = 4000 }; enemyClipNames[UnitType.Grunt] = "enemy"; settings[UnitType.Grunt] = unitSettings; unitLists[UnitType.Grunt] = new List <Unit>(20); } { unitSettings = new Settings { Health = 100, Damage = 30, AttackInterval = 0.1f, Speed = 4000 }; enemyClipNames[UnitType.Captain] = "enemy"; settings[UnitType.Captain] = unitSettings; unitLists[UnitType.Captain] = new List <Unit>(20); } { unitSettings = new Settings { Health = 100, Damage = 30, AttackInterval = 0.1f, Speed = 4000 }; enemyClipNames[UnitType.Boss] = "enemy"; settings[UnitType.Boss] = unitSettings; unitLists[UnitType.Boss] = new List <Unit>(20); } { unitSettings = new Settings { Health = 100, Damage = 40, AttackInterval = 0.1f, Speed = 4000 }; enemyClipNames[UnitType.Knight] = "knight"; settings[UnitType.Knight] = unitSettings; unitLists[UnitType.Knight] = new List <Unit>(20); } for (int i = 0; i < NUM_LANES; ++i) { lanes[i] = LANE_START + (i * LANE_OFFSET); } laneCategories[0] = (Category)SpinelessCollisionCategories.Lane1; laneCategories[1] = (Category)SpinelessCollisionCategories.Lane2; laneCategories[2] = (Category)SpinelessCollisionCategories.Lane3; for (int i = 0; i < 10; ++i) { Create(UnitType.Grunt); Create(UnitType.Captain); Create(UnitType.Boss); Create(UnitType.Knight); } }
static Engine() { behaviourManager = new BehaviourManager(); rendererManager = new RendererManager(); }
public MainWindowViewModel(IWindowManager windowManager, SimpleContainer container) { _windowManager = windowManager; _container = container; _sensorsToGraph = new ObservableCollection<GraphableSensor>(); SensorsToCheckMethodsAgainst = new ObservableCollection<Sensor>(); _erroneousValuesFromDataTable = new List<ErroneousValue>(); #region Set Up Detection Methods ShowLastZoom = false; _minMaxDetector = new MinMaxDetector(); _minMaxDetector.GraphUpdateNeeded += () => { SampleValues(Common.MaximumGraphablePoints, _sensorsToGraph, "MinMaxDetectorGraphUpdate"); CalculateYAxis(false); }; _runningMeanStandardDeviationDetector = new RunningMeanStandardDeviationDetector(); _runningMeanStandardDeviationDetector.GraphUpdateNeeded += () => SampleValues(Common.MaximumGraphablePoints, _sensorsToGraph, "RunningMeanGraphUpdate"); _runningMeanStandardDeviationDetector.RefreshDetectedValues += () => CheckTheseMethods(new Collection<IDetectionMethod> { _runningMeanStandardDeviationDetector }); _missingValuesDetector = new MissingValuesDetector { IsEnabled = true }; _selectedMethod = _missingValuesDetector; var repeatedValuesDetector = new RepeatedValuesDetector(); repeatedValuesDetector.RefreshDetectedValues += () => CheckTheseMethods(new Collection<IDetectionMethod> { repeatedValuesDetector }); _detectionMethods = new List<IDetectionMethod> { _missingValuesDetector, repeatedValuesDetector, _minMaxDetector, new ToHighRateOfChangeDetector(), _runningMeanStandardDeviationDetector }; #endregion #region Set Up Behaviours var behaviourManager = new BehaviourManager { AllowMultipleEnabled = true }; #region Zoom Behaviour _zoomBehaviour = new CustomZoomBehaviour { IsEnabled = true }; _zoomBehaviour.ZoomRequested += (o, e) => { ZoomState z = new ZoomState(StartTime, EndTime, Range); _previousZoom.Add(z); StartTime = e.LowerX; EndTime = e.UpperX; Range = new DoubleRange(e.LowerY, e.UpperY); foreach (var detectionMethod in _detectionMethods.Where(x => x.IsEnabled)) { var itemsToKeep = detectionMethod.ListBox.Items.Cast<ErroneousValue>().Where( x => x.TimeStamp >= StartTime && x.TimeStamp <= EndTime) .ToList(); detectionMethod.ListBox.Items.Clear(); itemsToKeep.ForEach(x => detectionMethod.ListBox.Items.Add(x)); } foreach (var sensor in _sensorsToGraph) { sensor.SetUpperAndLowerBounds(StartTime, EndTime); } SampleValues(Common.MaximumGraphablePoints, _sensorsToGraph, "Zoom"); ShowLastZoom = true; }; _zoomBehaviour.ZoomResetRequested += o => { _previousZoom.Clear(); foreach (var sensor in _sensorsToGraph) { sensor.RemoveBounds(); } CalculateGraphedEndPoints(); SampleValues(Common.MaximumGraphablePoints, _sensorsToGraph, "ZoomReset"); CalculateYAxis(); CheckTheseMethods(_detectionMethods.Where(x => x.IsEnabled)); ShowLastZoom = false; _previousZoom.Clear(); }; _zoomBehaviour.LastZoomRequested += (o, e) => { if (ShowLastZoom == true) { ZoomState z = _previousZoom.GetLast(); StartTime = z.StartTime; EndTime = z.EndTime; Range = z.Range; foreach (var detectionMethod in _detectionMethods.Where(x => x.IsEnabled)) { var itemsToKeep = detectionMethod.ListBox.Items.Cast<ErroneousValue>().Where( x => x.TimeStamp >= StartTime && x.TimeStamp <= EndTime) .ToList(); detectionMethod.ListBox.Items.Clear(); itemsToKeep.ForEach(x => detectionMethod.ListBox.Items.Add(x)); } foreach (var sensor in _sensorsToGraph) { sensor.SetUpperAndLowerBounds(StartTime, EndTime); } SampleValues(Common.MaximumGraphablePoints, _sensorsToGraph, "Zoom"); if (_previousZoom.Count == 0) { ShowLastZoom = false; } } }; behaviourManager.Behaviours.Add(_zoomBehaviour); #endregion #region Background Behaviour _background = new Canvas { Visibility = Visibility.Collapsed }; var backgroundBehaviour = new GraphBackgroundBehaviour(_background); behaviourManager.Behaviours.Add(backgroundBehaviour); #endregion #region Selection Behaviour _selectionBehaviour = new CustomSelectionBehaviour { IsEnabled = true }; _selectionBehaviour.SelectionMade += (sender, args) => { Selection = args; }; _selectionBehaviour.SelectionReset += sender => { Selection = null; }; behaviourManager.Behaviours.Add(_selectionBehaviour); #endregion _dateAnnotator = new DateAnnotationBehaviour { IsEnabled = true }; behaviourManager.Behaviours.Add(_dateAnnotator); _calibrationAnnotator = new CalibrationAnnotatorBehaviour(this) { IsEnabled = true }; behaviourManager.Behaviours.Add(_calibrationAnnotator); behaviourManager.Behaviours.Add(new ChangesAnnotatorBehaviour(this) { IsEnabled = true }); Behaviour = behaviourManager; #endregion PropertyChanged += (o, e) => { if (e.PropertyName == "Selection") ActionsEnabled = Selection != null; }; BuildDetectionMethodTabItems(); var autoSaveTimer = new System.Timers.Timer(); autoSaveTimer.Elapsed += (o, e) => { if (CurrentDataset != null) { Save(); } }; autoSaveTimer.AutoReset = true; autoSaveTimer.Interval = Properties.Settings.Default.AutoSaveTimerInterval; if (Properties.Settings.Default.AutoSaveTimerEnabled) autoSaveTimer.Start(); Properties.Settings.Default.PropertyChanged += (o, e) => { switch (e.PropertyName) { case "AutoSaveTimerInterval": autoSaveTimer.Interval = Properties.Settings.Default. AutoSaveTimerInterval; break; case "AutoSaveTimerEnabled": if (Properties.Settings.Default.AutoSaveTimerEnabled) autoSaveTimer.Start(); else autoSaveTimer.Stop(); break; } }; }
public AutomaticMixer() { _behaviourManager = new BehaviourManager(); _gatheringService = new GatheringService(); _gatheringService.AudioSessionUpdate.Subscribe(args => OnMixerStateUpdate(_gatheringService, args)); }
private void OnDestroy() { BehaviourManager.UnregisterBehaviour(this); client_peer?.Shutdown(); }
private void Awake() { BehaviourManager.RegisterBehaviour(this); Query.Initialize(); OnInit(); }
async void Start() { _log.Info("-------LOG STARTED----"); MainUI.Instance.ShowLoginWindow("", ""); //load behaviours if (Directory.Exists(Path.Combine(Application.dataPath, behavioursPath))) { BehaviourManager.LoadBehaviours(Path.Combine(Application.dataPath, behavioursPath)); } else { _log.Info($"Path {Path.Combine(Application.dataPath, behavioursPath)} not exists, skipping assembly loading"); } string sconfig = @" akka{ actor{ serializers { hyperion = ""Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion"" } serialization-bindings { ""System.Object"" = hyperion } provider=""Akka.Remote.RemoteActorRefProvider,Akka.Remote"" } remote{ helios.tcp{ transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"" port =18098 hostname=localhost } } } "; var config = ConfigurationFactory.ParseString(sconfig); _clientId = Guid.NewGuid(); try { AkkaSystem = ActorSystem.Create("JediumClient" + _clientId, config); } catch (Exception e) { Debug.Log(e); // throw; } DeadRequestProcessingActor.Install(AkkaSystem); }
public bool Start() { _logger = LogManager.GetLogger("[MainHost]"); _logger.Info("------------------------------JEDIUM SERVER---------------------------"); _logger.Info("Starting at: " + DateTime.Now); //settings var parser = new FileIniDataParser(); IniData data = parser.ReadFile("ServerConfig.ini"); MainSettings.BehavioursPluginPath = data["Server"]["BehavioursPluginPath"]; MainSettings.WebApiHost = data["Server"]["WebApiHost"]; MainSettings.DBUrl = data["Server"]["DBUrl"]; MainSettings.DatabaseName = data["Server"]["DatabaseName"]; MainSettings.CollectMessageStats = bool.Parse(data["Statistics"]["CollectMessageStats"]); MainSettings.StatsCollectionInterval = int.Parse(data["Statistics"]["StatsCollectionInterval"]); MD5 mcalc = MD5.Create(); byte[] dbytes = File.ReadAllBytes("Domain.dll"); MainSettings.ServerHash = mcalc.ComputeHash(dbytes).ToHex(false); _logger.Info($"Server domain hash: {MainSettings.ServerHash}"); //load plugins BehaviourManager.LoadBehaviours(MainSettings.BehavioursPluginPath); //get config (app.config) AkkaConfigurationSection section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka"); Config aconfig = section.AkkaConfig; //попытаться запустить актер сервера try { _system = ActorSystem.Create("VirtualFramework", aconfig); } catch (Exception ex) { _logger.Error(ex.Message); throw; } // на случай разрыва соединения DeadRequestProcessingActor.Install(_system); _databaseAgent = _system.ActorOf(Props.Create(() => new MongoDbActor()), "DataBase") .Cast <DatabaseAgentRef>(); //TODO: Add test for connection _terminal = _system.ActorOf(Props.Create(() => new TerminalConnection(_databaseAgent)), "Terminal") .Cast <TerminalConnectionRef>(); _serverConnection = _system .ActorOf(Props.Create(() => new ServerConnection(_databaseAgent)), "ServerEndpoint") .Cast <ConnectionRef>(); //TODO: find me //_databaseAgent.SetDummyObjectTest().Wait(); _manager = _system .ActorOf(Props.Create(() => new ObjectsManager(_databaseAgent, _serverConnection)), "ObjectManager") .Cast <ObjectsManagerRef>(); //assets host _webApiHost = _system .ActorOf(Props.Create(() => new WebApiHost(MainSettings.WebApiHost, _databaseAgent, _manager)), "AssetsHost") .Cast <WebApiHostRef>(); _pluginsHost = _system.ActorOf(Props.Create(() => new PluginsHost(_databaseAgent, _manager)), "PluginsHost") .Cast <PluginsHostRef>(); _pluginsHost.LoadPlugins().Wait(); _manager.LoadAllScenes().Wait(); return(true); }