public EventMoveTo(Game gameIn, mapManager mapIn, gameElement elementToMoveIn, Vector2 destinationIn, GameTime gameTimeIn) { this.SetEventName("Move To"); associatedMap = mapIn; associatedGame = gameIn; elementToMove = (ActorElement)elementToMoveIn; destination = destinationIn; gameTime = gameTimeIn; pathFound = false; flowMapProduced = false; noPathExists = false; movementWasPossible = false; nextListTarget = 0; reattemptCounter = 0; originalDestination = destination; moveGoingOn = false; currentPath = new List <Vector2>(); currentPath.Clear(); nodeList = new List <MapNode>(); nodeList.Clear(); //setup a bool array the size of the map to determine which places have already been reviewed checkedMap = new bool[associatedMap.getNumberTilesX(), associatedMap.getNumberTilesY()]; for (int x = 0; x < associatedMap.getNumberTilesX(); x++) { for (int y = 0; y < associatedMap.getNumberTilesY(); y++) { checkedMap[x, y] = false; } } }
public MobileActor(ActorElement ae, int retriesInSuperConnectedMode) { _myIp = IPAddress.Parse(ae.Ip); _triggersWebcamAlarm = ae.AlarmWebCam == "Y"; _retriesInSuperConnectedMode = retriesInSuperConnectedMode; Receive <Connected>(connected => { Logger.AddEvent(Self.Path.Name + " is definitely connected :-) !"); Become(Connected); }); Receive <Pinging>(message => { if (CheckIfConnected(Self.Path.Name)) { Become(Connected); } else { Become(Disconnected); } }); Receive <ReviewAlarmGroup>(@group => Sender.Tell(new ReviewAlarmGroup(false))); }
public KillSwitchActor(ActorSystem system) { _actorDiscovery = ClusterActorDiscovery.Get(system).Discovery; Flow <ActorDown>(b => { b.Action(ad => { Log.Info("Remove Killswitch Actor {Name}", ad.Actor.Path); _actors .FindIndex(ae => ae.Target.Equals(ad.Actor)) .When(i => i != -1, i => _actors.RemoveAt(i)); }); }); Flow <ActorUp>(b => { b.Func(au => { Log.Info("New killswitch Actor {Name}", au.Actor.Path); return(_actors .AddAnd(ActorElement.New(au.Actor)) .To(_ => new RequestRegistration())); }) .ToRefFromMsg(au => au.Actor) .Then <RespondRegistration>(b1 => { b1.Action(r => { Log.Info("Set Killswitch Actor Type {Type} {Name}", r.RecpientType, Context.Sender.Path); _actors .Find(e => e.Target.Equals(Context.Sender)) .When(i => i != null, element => element.RecpientType = r.RecpientType); }); }); }); Flow <RequestRegistration>(b => b.Func(() => new RespondRegistration(KillRecpientType.Seed)) .ToSender()); Flow <KillClusterMsg>(b => b.Action(RunKillCluster)); Flow <KillNode>(b => b.Action(_ => { Log.Info("Leaving Cluster"); Cluster.Get(Context.System).LeaveAsync(); })); Flow <ActorUp>(b => b.Action(au => au.When(u => u.Tag == "None", up => { Log.Info("Incoming kill Watcher {Name}", up.Actor.Path); Context.Watch(up.Actor); })) .Then <Terminated>(b1 => b1.Func(t => new ActorDown(t.ActorRef, "None")).ToSelf())); }
public EventHarvestTrees(Game gameIn, mapManager mapIn, EventManager eventManagerIn, gameElement focusElementIn, GameTime gameTimeIn, bool repeatingIn) { repeating = repeatingIn; associatedGame = gameIn; associatedEventManager = eventManagerIn; associatedMap = mapIn; gameTime = gameTimeIn; focusElement = (ActorElement)focusElementIn; treeLocation = new Vector2(-1, -1); nextToTree = false; seekingTree = false; }
public bool SetAssociated(ActorElement associatedActorIn) { if (associatedActorIn.Idle()) { associatedActorIn.SetIdle(false); actorToWake = associatedActorIn; return(true); } else { return(false); } }
public EventHarvestRocks(Game gameIn, mapManager mapIn, EventManager eventManagerIn, gameElement focusElementIn, GameTime gameTimeIn, bool repeatingIn) { repeating = repeatingIn; associatedGame = gameIn; associatedEventManager = eventManagerIn; associatedMap = mapIn; gameTime = gameTimeIn; focusElement = (ActorElement)focusElementIn; retryCounter = 0; rockLocation = new Vector2(-1, -1); nextToRock = false; seekingRock = false; }
public WebCamActor(ActorElement ae) { IPAddress ip = IPAddress.Parse(ae.Ip); var type = Type.GetType(ae.WebCamModel); if (type == null) { throw new ApplicationException("The webcam model " + ae.WebCamModel + " cannot be found in the list of available supported web cams. Please review the config file."); } _physicalWebcam = (IWebcam)Activator.CreateInstance(type, ae.WebCamUsername, ae.WebCamPassword, ip, Int32.Parse(ae.WebCamPort)); _pushBullet = new Pushbullet(ae.PushbulletKey, ae.PushbulletDeviceToSendMessagesTo); Become(Disalarmed); }
public static Props Props(ActorElement ae, int retriesInSuperConnectedMode) { return(Akka.Actor.Props.Create(() => new MobileActor(ae, retriesInSuperConnectedMode))); }
/// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { //Update key presses inputManager.Update(); //Check for key presses if (inputManager.EscapeButtonPressed()) { Exit(); } if (inputManager.SpawnTreeButtonReleased()) { eventManager.AddEvent(new EventAddTrees(this, currentMap, 1, 1, 0)); } if (inputManager.SpawnRockButtonReleased()) { eventManager.AddEvent(new EventAddRocks(this, currentMap, 1)); } //Check left mouse functions if (inputManager.LeftMouseButtonReleased()) { if (inputManager.DragFinished()) { elementFocus.Clear(); currentMap.GetAllElementsInArea(elementFocus, inputManager.GetMouseDragStartTile(), inputManager.GetMouseDragEndTile()); } else if (inputManager.MouseOverMap() && currentMap.getOccupied(inputManager.GetCurrentMouseTile(currentMap))) { currentMap.getOccupyingElement(inputManager.GetCurrentMouseTile(currentMap)).UpdateCurrentHealth(5); elementFocus.Clear(); elementFocus.Add(currentMap.getOccupyingElement(inputManager.GetCurrentMouseTile(currentMap))); } else if (uiManager.OverHarvestIcon(inputManager) && elementFocus.Count > 0) { for (int i = 0; i < elementFocus.Count; i++) { if (elementFocus[i].GetMovable()) { ((ActorElement)elementFocus[i]).SetJob(new GathererJob()); } } } else if (uiManager.OverMineIcon(inputManager) && elementFocus.Count > 0) { for (int i = 0; i < elementFocus.Count; i++) { if (elementFocus[i].GetMovable()) { eventManager.AddEvent(new EventHarvestRocks(this, currentMap, eventManager, elementFocus[i], gameTime, true)); } } } else { elementFocus.Clear(); } } //Check right mouse functions if (inputManager.RightMouseButtonReleased()) { //cycle through all focuses for (int i = 0; i < elementFocus.Count; i++) { if (elementFocus[i].GetMovable()) { //This is an actor ActorElement currentActor = (ActorElement)elementFocus[i]; //clear any previous stuck condition currentActor.SetStuck(false); EventMoveTo movingEvent = new EventMoveTo(this, currentMap, elementFocus[i], inputManager.GetCurrentMouseTile(currentMap), gameTime); if (currentActor.Moving()) { currentActor.ReplaceLinkedMovement(movingEvent); eventManager.AddEvent(movingEvent); } else { currentActor.LinkToMoveEvent(movingEvent); eventManager.AddEvent(movingEvent); } } } if (elementFocus.Count == 0) { //if no focus, spawn elements to test with if (!currentMap.getOccupied(inputManager.GetCurrentMouseTile(currentMap))) { currentMap.setOccupied(inputManager.GetCurrentMouseTile(currentMap), true); //currentMap.setOccupyingElement(inputManager.GetCurrentMouseTile(currentMap), new WorkerElement(this, (int)inputManager.GetCurrentMouseTile(currentMap).X, (int)inputManager.GetCurrentMouseTile(currentMap).Y)); currentMap.setOccupyingElement(inputManager.GetCurrentMouseTile(currentMap), new WaterElement(this, (int)inputManager.GetCurrentMouseTile(currentMap).X, (int)inputManager.GetCurrentMouseTile(currentMap).Y, currentMap)); } } } //Process jobs //TODO make run for everyone if (elementFocus.Count > 0) { if (elementFocus[0].HasJob() && elementFocus[0].Idle()) { ((ActorElement)elementFocus[0]).SetIdle(true); ((ActorElement)elementFocus[0]).GetJob().ProcessJobPriorities(this, currentMap, eventManager, elementFocus[0], gameTime); } } //Run events eventManager.RunEvents(); base.Update(gameTime); }
protected override void ConfigImpl() { Receive <ActorDown>(obs => obs.Do(ad => Log.Info($"Remove KillSwitch Actor {ad.Event.Actor.Path}")) .Select(m => { var(actorDown, state, _) = m; var entry = state.Actors.Find(e => e.Target.Equals(actorDown.Actor)); if (entry == null) { return(state); } return(state with { Actors = state.Actors.Remove(entry) }); })); Receive <ActorUp>(obs => obs.Do(au => Log.Info($"New killswitch Actor {au.Event.Actor.Path}")) .Select(m => { var(actorUp, state, _) = m; actorUp.Actor.Tell(new RequestRegistration()); return(state with { Actors = state.Actors.Add(ActorElement.New(actorUp.Actor)) }); })); Receive <RespondRegistration>(obs => obs .Do(r => Log.Info($"Set Killswitch Actor Type {r.Event.RecpientType} {Sender.Path}")) .Select(r => { var(respondRegistration, state, _) = r; var ele = state.Actors.Find(e => e.Target.Equals(Sender)); if (ele == null) { return(state); } return(state with { Actors = state.Actors.Replace(ele, ele with { RecpientType = respondRegistration.RecpientType }) }); })); Receive <RequestRegistration>(obs => obs.Select(_ => new RespondRegistration(KillRecpientType.Seed)) .ToSender()); Receive <KillClusterMsg>(obs => obs.SubscribeWithStatus(_ => RunKillCluster())); Receive <KillNode>(obs => obs.Do(_ => Log.Info("Leaving Cluster")) .SubscribeWithStatus(_ => Cluster.Get(Context.System).LeaveAsync())); Receive <ActorUp>(obs => obs.Where(m => m.Event.Tag == nameof(KillWatcher)) .Do(up => Log.Info($"Incomming Kill Watcher {up.Event.Actor.Path}")) .Select(m => m.Event.Actor) .SubscribeWithStatus(actor => Context.Watch(actor))); Receive <Terminated>(obs => obs.Select(t => new ActorDown(t.Event.ActorRef, nameof(KillWatcher))) .ToSelf()); Start.Subscribe(_ => { var actorDiscovery = ClusterActorDiscovery.Get(ObservableActor.Context.System).Discovery; actorDiscovery.Tell(new RegisterActor(Self, KillSwitchName)); actorDiscovery.Tell(new MonitorActor(nameof(KillSwitchName))); }); }
public static Props Props(ActorElement ae) { return(Akka.Actor.Props.Create(() => new WebCamActor(ae))); }