public void Setup() { IStatus StatusOk = new OkStatus(); IStatus StatusCalculating = new CalculatingStatus(); this.StatusOk = StatusOk; this.StatusCalculating = StatusCalculating; }
private void HandlePwAuthReq(Who sender, Message msg) { if (!server) { // we're a client that got a request, likely we're talking to a // server that is confused. return; } Console.WriteLine(" Sender: " + sender); Console.WriteLine(" Message: " + msg); String u = (String)msg.Get(mf_user); String p = (String)msg.Get(mf_password); try { OkStatus as1 = (OkStatus)SessionQuery(new UserPassword(u, p)); if (as1.ok) { SessionNotifyUser(u, p); } else { SessionNotifyUser(null, null); } sendPwAuthResp(sender, msg, as1.ok, as1.status); } catch (Exception e) { SessionNotifyUser(null, null); sendPwAuthResp(sender, msg, false, e.ToString()); throw e; } }
public override void OnNPCAtJob(ref NPCBase.NPCState state) { var status = ItemId.GetItemId(GameInitializer.NAMESPACE + ".Waiting"); var cooldown = COOLDOWN; var allActionsComplete = false; bool actionFound = false; try { if (TargetObjective != null && NPC != null) { NPC.LookAt(TargetObjective.Position.Vector); foreach (var action in new Dictionary <string, float>(TargetObjective.ActionEnergy)) { if (action.Value < .5f) { if (TargetObjective.RoamingJobSettings.ActionCallbacks.TryGetValue(action.Key, out var roamingJobObjective)) { status = roamingJobObjective.PreformAction(Owner, TargetObjective); cooldown = roamingJobObjective.TimeToPreformAction; AudioManager.SendAudio(TargetObjective.Position.Vector, roamingJobObjective.AudioKey); actionFound = true; } } } if (!actionFound) { PreviousObjective = null; TargetObjective.JobRef = null; TargetObjective = null; allActionsComplete = true; } } // if the objective is gone, Abort. CheckIfValidObjective(); if (OkStatus.Contains(status)) { if (actionFound) { ActionsPreformed++; } _stuckCount = 0; } else if (status != 0) { _stuckCount++; } if (_stuckCount > 5 || TargetObjective == null) { state.JobIsDone = true; status = ItemId.GetItemId(GameInitializer.NAMESPACE + ".Waiting"); if (allActionsComplete) { cooldown = 0.5f; } if (_stuckCount > 5) { PreviousObjective = TargetObjective; TargetObjective.JobRef = null; TargetObjective = null; } } if (OkStatus.Contains(status)) { state.SetIndicator(new IndicatorState(cooldown, status.Id)); } else if (status != 0) { state.SetIndicator(new IndicatorState(cooldown, status.Id, true)); } else { state.SetIndicator(new IndicatorState(cooldown, ColonyBuiltIn.ItemTypes.MISSINGERROR.Name)); } } catch (Exception ex) { APILogger.LogError(ex); } state.SetCooldown(cooldown); }