public void UpdatetReticleLabel() { string _labelText = ""; if (hoverActor != null) { if (hoverActor) { _labelText = lockedSelectionString + hoverActor.GetDisplayName(); } if (currentTool != null) { if (currentTool.GetReticleText() != "") { _labelText = lockedSelectionString + currentTool.GetReticleText(); } } } else { if (lockedSelectionString != null) { _labelText = lockedSelectionString; } } reticleLabel.text = _labelText; }
private bool ShouldActorBeListed(bool isOffstageList, VoosActor actor) { return(actor.GetName() != "__GameRules__" && (actor.GetIsOffstageEffective() == isOffstageList) && !actor.GetWasClonedByScript() && (actor.GetDisplayName().ToLower().Contains(searchInput.text.ToLower()))); }
private void ActorUpdate(VoosActor actor) { assetUI.header.text = $"{actor.GetDisplayName()} : Rotate"; UpdateVec3Input(actor.GetRotation().eulerAngles, assetUI.currentInputs); UpdateVec3Input(actor.GetSpawnRotation().eulerAngles, assetUI.spawnInputs); UpdateVec3Input(actor.GetRenderableRotation().eulerAngles, assetUI.offsetInputs); }
public void Put(string id, VoosActor actor, Texture2D thumbnail) { string json = ExportToJson(actor, thumbnail); Sojo sojo = new Sojo(ToSojoId(id), actor.GetDisplayName(), SojoType.ActorPrefab, json); sojoSystem.PutSojo(sojo); }
private bool ShouldActorBeListed(bool isOffstageList, VoosActor actor) { return((actor.GetIsOffstageEffective() == isOffstageList) && !actor.GetWasClonedByScript() && (showCopiesToggle.isOn || actor.GetCloneParentActor() == null) && actor.GetDisplayName().ToLower().Contains(searchInput.text.ToLower())); }
public void DrawActorDebugGUI(VoosActor actor) { using (new Util.GUILayoutFrobArea(actor.transform.position, 100, 500)) { PhotonView photonView = PhotonView.Get(actor); if (photonView == null) { return; } PlayerBody playerBody = actor.GetPlayerBody(); //string pbodyInfo = playerBody == null ? "" : $"Claimed? {playerBody.IsClaimed()} ..play mode? {playerBody.GetIsClaimerPlaying()}"; string color = photonView.isMine ? "yellow" : "grey"; string hash = actor.GetName().Substring(0, 9); bool locked = actor.IsLockedByAnother() || actor.IsLockWantedLocally(); string lockingString = locked ? " LOCKED" : ""; string lastPos = actor.unrel == null ? "" : actor.unrel.lastPosition.x.ToFourDecimalPlaces(); GUILayout.Label($@"<color={color}>{actor.GetDisplayName()} rot: {actor.GetRotation().ToFourDecimalPlaces()} last unrel: {actor.lastUnreliableUpdateTime} lastPX: {lastPos}</color>".Trim()); GUILayout.Toggle(actor.GetReplicantCatchUpMode(), "Catchup?"); actor.debug = GUILayout.Toggle(actor.debug, "Debug"); // owner: {photonView.ownerId}{lockingString} // {hash} view {actor.reliablePhotonView.viewID} // X: {actor.transform.position.x.ToFourDecimalPlaces()} // lastRBMPX: {actor.lastRBMovedPos.x.ToFourDecimalPlaces()} } }
private void ToggleActorOffstage(VoosActor toggleActor) { bool currentOffstage = toggleActor.GetPreferOffstage(); if (!toggleActor.IsLockedByAnother() && !toggleActor.IsParentedToAnotherActor()) { undoStack.PushUndoForActor( toggleActor, $"Toggle offstage for {toggleActor.GetDisplayName()}", actor => { if (!actor.IsParentedToAnotherActor()) { actor.SetPreferOffstage(!currentOffstage); } }, actor => { if (!actor.IsParentedToAnotherActor()) { actor.SetPreferOffstage(currentOffstage); } }); RefreshActorList(); } }
private void RefreshUI() { nothingSelectedPrompt.gameObject.SetActive(false); multipleSelectedPrompt.gameObject.SetActive(false); clonePrompt.SetActive(false); lockedContentChecker.Close(); if (!isOpen) { return; } if (currActor == null) { NullActorRefresh(); } else if (currActor?.GetCloneParent() != null && currActor.GetCloneParent() != "") { clonePrompt.SetActive(true); VoosActor cloneParent = voosEngine.GetActor(currActor.GetCloneParent()); cloneMessage.text = $"This is a copy of {cloneParent.GetDisplayName()}"; } else { lockedContentChecker.Open(currActor, () => { showCallback(currActor); }, () => { hideCallback(false); }); } }
private void HandleBehaviorException(VoosEngine.BehaviorLogItem item) { MaybeNotifyUserOfBehaviorError(item); VoosActor actor = voosEngine.GetActor(item.actorId); string behDesc = GetBehaviorTitle(actor.GetBrainName(), item.useId); CommandTerminal.HeadlessTerminal.Buffer.HandleLog($"<color=yellow>[{actor.GetDisplayName()} '{behDesc}' on{item.messageName}:{item.lineNum}]</color> <color=red>{item.message}</color>", TerminalLogType.Error, null); }
void OnSoundPicked(string sfxId) { string lastSfxId = actor.GetSfxId(); undoStack.PushUndoForActor( actor, $"Set sound effect for {actor.GetDisplayName()}", actor => { actor.SetSfxId(sfxId); actor.ApplyPropertiesToClones(); }, actor => { actor.SetSfxId(lastSfxId); actor.ApplyPropertiesToClones(); }); }
private void SetActor(VoosActor actor) { SetCurrActor(actor); logicSidebarUI.label.text = actor?.GetDisplayName(); if (usingCardView) { cardTab.Open(actor); } }
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 BreakLink(bool withUndo = true) { VoosActor actor = currActor; // Save for undo string prevParent = actor.GetCloneParent(); SetActorInternal(null); actor.SetCloneParent(null); actor.MakeOwnCopyOfBrain(); if (withUndo) { // Setup undo item string actorName = actor.GetName(); string newBrain = actor.GetBrainName(); undo.Push(new UndoStack.Item { actionLabel = $"Break copy-link of {actor.GetDisplayName()}", getUnableToDoReason = () => ActorUndoUtil.GetUnableToEditActorReason(voosEngine, actorName), doIt = () => { var redoActor = voosEngine.GetActor(actorName); redoActor.SetCloneParent(null); // A bit sloppy: We're relying on the fact that brains are never deleted // (except on load). redoActor.SetBrainName(newBrain); OnBreakLinkChanged(redoActor); }, getUnableToUndoReason = () => { var prevParentActor = voosEngine.GetActor(prevParent); if (prevParentActor == null) { return($"The original copy no longer exists."); } return(null); }, undo = () => { var undoActor = voosEngine.GetActor(actorName); var prevParentActor = voosEngine.GetActor(prevParent); Debug.Assert(prevParent != null, "BreakLink undo action: prevParent does not exist anymore"); undoActor.SetCloneParent(prevParent); undoActor.SetBrainName(prevParentActor.GetBrainName()); OnBreakLinkChanged(undoActor); } }); } SetActorInternal(actor); }
void ToggleHideInPlayMode(bool value) { if (actor == null) { return; } bool prevValue = actor.GetHideInPlayMode(); undoStack.PushUndoForActor( actor, $"Set hide for {actor.GetDisplayName()}", actor => { actor.SetHideInPlayMode(value); actor.ApplyPropertiesToClones(); }, actor => { actor.SetHideInPlayMode(prevValue); actor.ApplyPropertiesToClones(); }); }
private void ParentCheck() { VoosActor actor = GetSingleTargetActor(); if (inputControl.GetButtonDown("Parent") && actor != null) { Debug.Log( "parenting " + actor.GetDisplayName() + " to " + (hoverActor != null ? hoverActor.GetDisplayName() : "(nothing)")); bool autosetParent = PlayerPrefs.GetInt("moveTool-autosetSpawn", 1) == 1 ? true : false; MoveToolSettings.SetCurrentParentForActor(actor, hoverActor, undoStack, autosetParent); } }
private void ActorUpdate(VoosActor actor) { assetUI.header.text = $"{actor.GetDisplayName()} : Move"; UpdateVec3Input(actor.GetPosition(), assetUI.currentInputs); UpdateVec3Input(actor.GetSpawnPosition(), assetUI.spawnInputs); UpdateVec3Input(actor.GetRenderableOffset(), assetUI.offsetInputs); VoosActor parent = actor.GetEngine().GetActor(actor.GetTransformParent()); assetUI.currentParentButtonText.text = parent != null?parent.GetDisplayName() : "<none>"; VoosActor spawnParent = actor.GetEngine().GetActor(actor.GetSpawnTransformParent()); assetUI.restartParentButtonText.text = spawnParent != null?spawnParent.GetDisplayName() : "<none>"; }
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); }
private string GetHeaderDescription() { if (currActor == null) { return(""); } string displayName = currActor.GetDisplayName(); if (displayName.Length > 10) { displayName = displayName.Substring(0, 10) + "..."; } return(displayName + ": " + content.GetCurrentTabName()); }
private void SetDraggingActor(VoosActor actor) { if (actor == draggingActor) { return; } draggingActor = actor; onStageList.SetDraggingActor(draggingActor); offStageList.SetDraggingActor(draggingActor); draggingGhost.gameObject.SetActive(draggingActor != null); if (actor != null) { draggingGhost.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = actor.GetDisplayName(); } }
public ActorInfo(VoosActor actor, EditMain editMain) { this.actor = actor; hierarchyPath = new List <ActorHierarchyInfo>(); for (VoosActor thisActor = actor; thisActor != null; thisActor = thisActor.GetParentActor()) { ActorHierarchyInfo info = new ActorHierarchyInfo(); info.name = thisActor.name; info.displayName = thisActor.GetDisplayName(); if (editMain != null) { info.distance = Vector3.Distance(editMain.GetAvatarPosition(), thisActor.GetPosition()); } hierarchyPath.Insert(0, info); } }
public void Populate(ICardModel unassignedCard) { if (unassignedCard == null || !unassignedCard.IsValid()) { return; } cardContainer = null; card.Populate(unassignedCard, true); if (unassignedCard.IsBuiltin()) { codeText.SetText("Duplicate and edit JavaScript"); trashButton.gameObject.SetActive(false); previewButton.gameObject.SetActive(true); } else { codeText.SetText("Edit JavaScript"); previewButton.gameObject.SetActive(false); string behaviorUri = unassignedCard.GetUnassignedBehaviorItem().behaviorUri; VoosActor user = voosEngine.FindOneActorUsing(behaviorUri); string fromActorLib = actorLib.FindOneActorUsingBehavior(behaviorUri); if (user != null) { trashText.SetText($"Cannot delete - used by actor '{user.GetDisplayName()}'"); trashButton.interactable = false; } else if (fromActorLib != null) { trashText.SetText($"Cannot delete - used by creation library actor '{fromActorLib}'"); trashButton.interactable = false; } else { trashText.SetText($"Remove card"); trashButton.interactable = true; } trashButton.gameObject.SetActive(true); } noPropertiesObject.SetActive(!card.HasAnyProps()); UpdateAddToSlotButton(); }
void MaybeNotifyUserOfBehaviorError(VoosEngine.BehaviorLogItem item) { // Errors are a big deal - quietly failing just leads to further confusion. // So, we're just gonna do popups. if (Time.unscaledTime - lastErrorPopupTime > 3f && (!IsCodeEditorOpen() || item.lineNum == -1)) { lastErrorPopupTime = Time.unscaledTime; var brainId = voosEngine.GetActor(item.actorId).GetBrainName(); var uri = behaviorSystem.GetBrain(brainId).GetUse(item.useId).behaviorUri; VoosActor actor = voosEngine.GetActor(item.actorId); string behDesc = GetBehaviorTitle(actor.GetBrainName(), item.useId); var niceMsg = $"Script error for actor '{actor.GetDisplayName()}' from card '{behDesc}':\n{item.message}"; string fullMessage = $"{niceMsg}\n<color=yellow>'on{item.messageName}' will be disabled until the script is edited or the game is reset.</color>\nYou may want to pause the game if the error is repeating."; onDisplayCodeError?.Invoke(fullMessage, uri, item); } }
SavedActorPrefab ToPrefab(VoosActor root, Texture2D thumbnail) { List <VoosActor.PersistedState> savedActors = new List <VoosActor.PersistedState>(); Behaviors.Database brainDatabase = new Behaviors.Database(); List <Sojo.Saved> sojos = new List <Sojo.Saved>(); void ExportActorRecursive(VoosActor actor) { savedActors.Add(actor.Save()); actor.GetBehaviorSystem().ExportBrain(actor.GetBrainName(), brainDatabase); foreach (string sojoId in GetUsedSojoIds(actor)) { Sojo sojo = sojoSystem.GetSojoById(sojoId); if (sojo == null) { Util.LogError($"Could not find sojo of id {sojoId} for actor {actor.name}"); continue; } sojos.Add(sojo.Save()); } foreach (VoosActor child in actor.GetChildActors()) { ExportActorRecursive(child); } } ExportActorRecursive(root); return(new SavedActorPrefab { version = SavedActorPrefab.CurrentVersion, label = root.GetDisplayName(), thumbnailJZB64 = System.Convert.ToBase64String(Util.TextureToZippedJpeg(thumbnail)), brainDatabase = brainDatabase.Save(), sojos = sojos.ToArray(), actors = savedActors.ToArray() }); }
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); } }
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 Show(VoosActor actor) { // Start with player 0 to avoid warnings/etc. AssignPlayerToActor(0, actor.GetName()); string name = actor.GetDisplayName(); List <PopupButton.Params> buttons = new List <PopupButton.Params>(); int myPlayerNumber = playerControlsManager.GetMyPlayerNumber(); int maxPlayerSlotNumber = 4; // Show at least player 1-4, unless there are more players. foreach (VirtualPlayerManager.VirtualPlayerInfo player in virtualPlayerManager.EnumerateVirtualPlayers()) { maxPlayerSlotNumber = Mathf.Max(player.slotNumber, maxPlayerSlotNumber); } for (int i = 1; i <= maxPlayerSlotNumber; i++) { int thisNumber = i; // For closures below buttons.Add(new PopupButton.Params { getLabel = () => $"Player {thisNumber}" + ((thisNumber == myPlayerNumber) ? " (myself)" : ""), onClick = () => OnClickedPlayerNumber(actor, thisNumber) }); } buttons.Add(new PopupButton.Params { getLabel = () => "Nobody for now", onClick = () => OnClickedPlayerNumber(actor, 0) }); buttons.Add(new PopupButton.Params { getLabel = () => "It's an NPC", onClick = () => OnClickedIsNpc(actor) }); popups.Show(new DynamicPopup.Popup { getMessage = () => $"Who will control this {name}?", buttons = buttons, }); }
public void DeleteTargetActors() { VoosActor builtin = targetActors.FirstOrDefault(a => a.IsBuiltinActor()); if (builtin != null) { popups.Show($"Sorry, built-in actors such as {builtin.GetDisplayName()} cannot be deleted.", "OK"); } var deletableActors = targetActors.Where(a => a != null && !a.IsLockedByAnother() && !a.IsBuiltinActor()).ToList(); if (deletableActors.Count == 0) { return; } var actorStates = engine.SaveActorHierarchy(deletableActors); var label = deletableActors.Count > 1 ? $"Delete {deletableActors.Count} actors" : $"Delete {deletableActors[0].GetDisplayName()}"; undoStack.Push(new UndoStack.Item { actionLabel = label, getUnableToDoReason = () => null, getUnableToUndoReason = () => null, doIt = () => { foreach (var state in actorStates) { ActorUndoUtil.GetValidActorThen( engine, state.name, validActor => this.DeleteActor(validActor)); } }, undo = () => engine.RestoreActorHierarchy(actorStates) }); SetCameraFollowingActor(false); }
private void Paste() { List <VoosEngine.CopyPasteActorRequest> copyPasteRequests = new List <VoosEngine.CopyPasteActorRequest>(); foreach (KeyValuePair <VoosActor, GameObject> entry in pastePreview) { if (entry.Key == null) { continue; } VoosActor baseActor = entry.Key.GetCloneParentActor() ?? entry.Key; if (baseActor.IsLockedByAnother() || baseActor == null) { continue; } int count = voosEngine.CountCopiesOf(baseActor); string baseName = baseActor.GetDisplayName(); string copyName = baseName + "-" + (count + 1); Vector3 position = entry.Value.transform.position; Quaternion rotation = entry.Key.GetRotation(); copyPasteRequests.Add(new VoosEngine.CopyPasteActorRequest { source = entry.Key, pastedPosition = position, pastedRotation = rotation, pastedDisplayName = copyName }); } List <VoosActor> pastedActors = voosEngine.CopyPasteActors(copyPasteRequests); undoStack.PushUndoForCreatingActors(pastedActors, $"Paste {pastedActors.Count} actors"); }
private void SetPlayerNumberOnPlayerControlsPanel(VoosActor actor, Behaviors.BehaviorUse use, int playerNumber) { use = use.DeepClone(); use.SetPropertyValue(PLAYER_NUMBER_PROP_NAME, playerNumber); Behaviors.Brain brain = actor.GetBehaviorSystem().GetBrain(actor.GetBrainName()); if (brain == null) { Debug.LogErrorFormat("Could not set player# on actor {0} ({1}). No brain.", actor.GetName(), actor.GetDisplayName()); return; } brain.SetUse(use); actor.GetBehaviorSystem().PutBrain(actor.GetBrainName(), brain); }
private void DeletePlayerControlsPanel(VoosActor actor) { Debug.Assert(actor.IsLocallyOwned(), "Actor should be locally owned"); Behaviors.BehaviorUse playerControlsPanel = TryGetPlayerControlsPanel(actor); if (playerControlsPanel == null) { return; } Behaviors.Brain brain = actor.GetBehaviorSystem().GetBrain(actor.GetBrainName()); if (brain == null) { Debug.LogErrorFormat("Could not set player# on actor {0} ({1}). No brain.", actor.GetName(), actor.GetDisplayName()); return; } // PLAYER_CONTROLS_PANEL_HAS_NO_DECKS_ASSUMPTION // WARNING: this is a naive delete that doesn't recursively look for behavior uses mentioned // in any decks used by the Player Controls panel, so if in the future we do add decks to it, // we need to update this logic to remove the panel properly. brain.DeleteUse(playerControlsPanel.id); actor.GetBehaviorSystem().PutBrain(actor.GetBrainName(), brain); }