private void HandleBehaviorLogMessage(VoosEngine.BehaviorLogItem item) { UpdateFloodDetection(); if (item.message.Contains("ERROR: ")) { MaybeNotifyUserOfBehaviorError(item); } VoosActor actor = voosEngine.GetActor(item.actorId); string behDesc = GetBehaviorTitle(actor.GetBrainName(), item.useId); CommandTerminal.HeadlessTerminal.Buffer.HandleLog($"<color=#666666>[{actor.GetDisplayName()} '{behDesc}' on{item.messageName}:{item.lineNum}]</color> <color=white>{item.message}</color>", TerminalLogType.Message, null); }
private void UpdateCameraActor() { VoosActor curCameraActor = navigationControls.GetCameraView() == CameraView.ActorDriven ? navigationControls.GetActorDrivenCameraActor() : null; VoosActor requiredCameraActor = (editMode || GetPlayerActor() == null) ? null : string.IsNullOrEmpty(GetPlayerActor().GetCameraActor()) ? null : voosEngine.GetActor(GetPlayerActor().GetCameraActor()); // Are things already as they should be? if (curCameraActor == requiredCameraActor) { // Things are already as they should be. return; } if (requiredCameraActor != null) { navigationControls.SwitchToActorDrivenCamera(requiredCameraActor); } else { // TODO: preserve previous camera view so we can come back to the same one // when returning to edit mode? // navigationControls.SetCameraView(CameraView.Isometric); navigationControls.SetCameraView(editCameraView); } }
// Best-effort semantics. This will silently fail and just not call thenFunc // is the actor can't be found or can't be owned before timeout. public static void GetValidActorThen( VoosEngine engineRef, string actorName, System.Action <VoosActor> thenFunc) { VoosActor currentActor = engineRef.GetActor(actorName); if (currentActor == null) { return; } currentActor.RequestOwnershipThen(() => thenFunc(currentActor)); }
// Another player requested that a sound be played. private void OnNetworkSfxRequest(SfxPlayRequest request) { SoundEffect effect = GetSoundEffect(request.sfxId); if (effect == null) { return; } VoosActor actor = string.IsNullOrEmpty(request.actorName) ? null : engine.GetActor(request.actorName); PlaySoundEffectLocal(effect, actor, request.position); }
public static string GetUnableToEditActorReason(VoosEngine engineRef, string actorName) { VoosActor currentActor = engineRef.GetActor(actorName); if (currentActor == null) { return($"The actor does not exist anymore."); } if (currentActor.IsLockedByAnother()) { return($"{currentActor.GetLockingOwnerNickName()} is editing '{currentActor.GetDisplayName()}'."); } return(null); }
public string ToUserFriendlyString(VoosEngine engine) { switch (mode) { case Mode.NONE: return("(Nothing)"); case Mode.BY_TAG: return((tagOrName == "player") ? "(Player)" : "Tag: " + tagOrName); case Mode.BY_NAME: VoosActor actor = engine.GetActor(tagOrName); return(actor != null?actor.GetDisplayName() : "(invalid)"); case Mode.ANY: return("(any actor)"); default: throw new System.Exception("Invalid mode " + mode); } }
void OnActorEntryClicked(HierarchyActorEntry entry, HierarchyActorEntry.ActionType actionType) { // The user has clicked on an actor in the list. VoosActor actor = engine.GetActor(entry.GetActorName()); if (actor == null) { // Shouldn't happen. Debug.LogError("Clicked on actor that doesn't exist " + entry.GetActorName() + ". Bug?"); return; } if (selectCallback != null) { selectCallback(actor); selectCallback = null; return; } switch (actionType) { case HierarchyActorEntry.ActionType.SELECT: if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { AddActorToSelection(actor); } else { SelectActor(actor); } break; case HierarchyActorEntry.ActionType.INFO: SelectActor(actor, true); break; case HierarchyActorEntry.ActionType.MOVE: ToggleActorOffstage(actor); break; } }
public static void PushUndoForMany(this UndoStack stack, VoosEngine engine, IEnumerable <VoosActor> actors, string verb, System.Action <VoosActor> doIt, System.Action <VoosActor> undo) { List <string> actorNames = (from actor in actors select actor.GetName()).ToList(); if (actorNames.Count == 1) { // Special case this to be the fancier. string actorName = actorNames[0]; if (GetUnableToEditActorReason(engine, actorName) == null) { VoosActor actor = engine.GetActor(actorName); stack.PushUndoForActor(actor, $"{verb} {actor.GetDisplayName()}", doIt, undo); } return; } stack.Push(new UndoStack.Item { actionLabel = $"{verb} {actorNames.Count} actors", // We'll just do best effort for all this - so never block it. getUnableToDoReason = () => null, getUnableToUndoReason = () => null, doIt = () => { foreach (string name in actorNames) { GetValidActorThen(engine, name, doIt); } }, undo = () => { foreach (string name in actorNames) { GetValidActorThen(engine, name, undo); } } }); }
public void Setup() { Util.FindIfNotSet(this, ref voosEngine); Util.FindIfNotSet(this, ref editMain); Util.FindIfNotSet(this, ref undo); Util.FindIfNotSet(this, ref popups); editOriginalButton.onClick.AddListener(() => { SetActorInternal(voosEngine.GetActor(currActor.GetCloneParent())); }); breakLinkButton.onClick.AddListener(() => BreakLink()); voosEngine.onBeforeActorDestroy += (actor) => { if (currActor != null && actor == currActor) { SetActorInternal(null); hideCallback(true); } }; }
public override void SetValue(string actorName) { actor = string.IsNullOrEmpty(actorName) ? null : engine.GetActor(actorName); buttonLabel.text = actor != null?actor.GetDisplayName() : "[Click to set]"; }