Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using UnityEngine;
- public class InputManager : MonoBehaviourSingleton<InputManager>
- {
- public static string Horizontal = "Horizontal";
- public static string Vertical = "Vertical";
- public static string Fire1 = "Fire1";
- public static string Fire2 = "Fire2";
- public static string Fire3 = "Fire3";
- public static string Jump = "Jump";
- public static string MouseX = "Mouse X";
- public static string MouseY = "Mouse Y";
- public static string MouseScrollWheel = "Mouse ScrollWheel";
- public static string WindowShakeX = "Window Shake X";
- public static string WindowShakeY = "Window Shake Y";
- public static string Back = "Back";
- public static string Inventory = "Inventory";
- public static string Character = "Character";
- public static string Journal = "Journal";
- public static string SelectParty = "Select Party";
- public static string GroupMode = "Toggle Group Mode";
- public static string RotateCameraLeft = "Rotate Camera Left";
- public static string RotateCameraRight = "Rotate Camera Right";
- public static string NextMob = "Select Next Mob";
- public static string ShowGrid = "Show Grid";
- public static string SwapWeapons = "Swap Weapons";
- public static string AreaAttack = "Area Attack";
- public static string HighlightAll = "Highlight All";
- public static string ShowAttackRange = "Show Attack Range";
- public static string SpawnTestParty = "Spawn Test Party";
- public static string HotkeyBase = "Hotkey ";
- public static string Hotkey1 = "Hotkey 1";
- public static string Hotkey2 = "Hotkey 2";
- public static string Hotkey3 = "Hotkey 3";
- public static string Hotkey4 = "Hotkey 4";
- public static string Hotkey5 = "Hotkey 5";
- public static string Hotkey6 = "Hotkey 6";
- public static string Hotkey7 = "Hotkey 7";
- public static string Hotkey8 = "Hotkey 8";
- public static string Hotkey9 = "Hotkey 9";
- public static string EndTurn = "End Turn";
- public static string SelectPlayer = "Select Player ";
- public static string SelectPlayer1 = "Select Player 1";
- public static string SelectPlayer2 = "Select Player 2";
- public static string SelectPlayer3 = "Select Player 3";
- public static string SelectPlayer4 = "Select Player 4";
- public static string SelectPlayer5 = "Select Player 5";
- public static string SelectPlayer6 = "Select Player 6";
- public static string SelectPlayer7 = "Select Player 7";
- public static string Map = "Map";
- public static string AttackTarget = "Attack Current Target";
- public static string ChangeMoveMode = "Change Move Mode";
- public static string Reload = "Reload";
- public static string ResetCameraRotation = "Reset Camera Rotation";
- public static string RadioScan = "Radio Scan";
- public static string RadioAcknowledge = "Radio Acknowledge";
- public static string QuickSave = "Quick Save";
- public static string QuickLoad = "Quick Load";
- public bool selectionRectActive = true;
- public List<Mob> selectedMobs = new List<Mob>();
- public List<PC> activePCs = new List<PC>();
- private List<Mob> selectedBackup = new List<Mob>();
- public float distFollowHangBack = 5f;
- public float distToFormationMax = 3f;
- private WSBool wsIsPartyMovementNotGrouped = WSBool.GetRef("UnGroupedMovement");
- private int layerMaskCombatPath = InputManager.layerMask_Terrain | InputManager.layerMask_Floor | InputManager.layerMask_Cover | InputManager.layerMask_DynamicObject | InputManager.layerMask_StaticMeshes | InputManager.layerMask_Mob;
- public float baseMoveStartDelay = 0.3f;
- public float rangeMoveStartDelay = 0.6f;
- public float[] MoveStartDelayScaleOfMoveMode = new float[4]
- {
- 1f,
- 0.5f,
- 1.5f,
- 1.5f
- };
- public const float doubleClickTime = 0.3f;
- public static string[] buttonEvents;
- public GameObject movePositionFxPrefab;
- public GameObject moveBlockedFxPrefab;
- private MoveCursor moveCursor;
- private BlockedCursor blockedCursor;
- public GUIStyle selectionRectStyle;
- private bool[] previousSelections;
- public bool holdForCombatPath;
- private CombatAStarNode mouseoverSquare;
- [HideInInspector]
- public bool bEdgeScrolling;
- [HideInInspector]
- public Vector4 cameraMove;
- private Vector3 mouseDownPos;
- private bool wasMouseDownShift;
- private bool wasMouseDownCtrl;
- private PC pcLeaderOnDragStart;
- private float rightClickUpTime;
- private float leftClickUpTime;
- private bool moveClick;
- private bool actionClick;
- private Vector3 clickPosition;
- private Vector3 lastRightClickPosition;
- public FormationTemplate formation;
- public FormationTemplate formationInstigate;
- private NavMeshHit navHit;
- private Vector3 lastMiddleClickPosition;
- public bool ignoreMousePosition;
- private Vector3 ignoredMousePosition;
- private float formationTimer;
- private bool formationSpinning;
- public float formationDelay;
- private CombatAStarNode lastCombatSquare;
- private CombatAStarNode timerCombatSquare;
- private float combatSquareTimer;
- private int cursorTextId;
- public static int layerIndex_Default;
- public static int layerIndex_TransparentFX;
- public static int layerIndex_IgnoreRaycast;
- public static int layerIndex_Water;
- public static int layerIndex_Terrain;
- public static int layerIndex_Mob;
- public static int layerIndex_DynamicObject;
- public static int layerIndex_StaticMeshes;
- public static int layerIndex_InventoryGUI;
- public static int layerIndex_HUD;
- public static int layerIndex_MiniMapIcon;
- public static int layerIndex_Floor;
- public static int layerIndex_Wall;
- public static int layerIndex_FadeOutOnly;
- public static int layerIndex_FadedFloor;
- public static int layerIndex_FadedWall;
- public static int layerIndex_Cover;
- public static int layerIndex_DressingRoom;
- public static int layerIndex_SpeechBubbles;
- public static int layerIndex_MovingObjects;
- public static int layerMask_Default;
- public static int layerMask_TransparentFX;
- public static int layerMask_IgnoreRaycast;
- public static int layerMask_Water;
- public static int layerMask_Terrain;
- public static int layerMask_Mob;
- public static int layerMask_DynamicObject;
- public static int layerMask_StaticMeshes;
- public static int layerMask_InventoryGUI;
- public static int layerMask_HUD;
- public static int layerMask_MiniMapIcon;
- public static int layerMask_Floor;
- public static int layerMask_Wall;
- public static int layerMask_FadeOutOnly;
- public static int layerMask_FadedFloor;
- public static int layerMask_FadedWall;
- public static int layerMask_Cover;
- public static int layerMask_DressingRoom;
- public static int layerMask_SpeechBubbles;
- public static int layerMask_MovingObjects;
- public static int navMeshLayerIndex_Default;
- public static int navMeshLayerIndex_Ladders;
- public static int navMeshLayerIndex_Door;
- private int freezeInputCount;
- private bool hasLostFocus;
- private bool isPartyMovementGrouped
- {
- get
- {
- return !(bool) this.wsIsPartyMovementNotGrouped;
- }
- set
- {
- this.wsIsPartyMovementNotGrouped.Set(!value);
- }
- }
- public bool isPartyGrouped
- {
- get
- {
- return this.isPartyMovementGrouped;
- }
- }
- public int movementPCsCount
- {
- get
- {
- if (this.isPartyGrouped)
- return MonoBehaviourSingleton<Game>.GetInstance(false).party.Count;
- else
- return this.activePCs.Count;
- }
- }
- public bool didDoubleRightClick
- {
- get
- {
- return (double) Time.time - (double) this.rightClickUpTime < 0.300000011920929;
- }
- }
- public bool didDoubleLeftClick
- {
- get
- {
- return (double) Time.time - (double) this.leftClickUpTime < 0.300000011920929;
- }
- }
- private bool freezeInput
- {
- get
- {
- return this.freezeInputCount > 0;
- }
- set
- {
- if (value)
- {
- ++this.freezeInputCount;
- }
- else
- {
- --this.freezeInputCount;
- if (this.freezeInputCount >= 0)
- return;
- this.freezeInputCount = 0;
- }
- }
- }
- static InputManager()
- {
- string[] strArray = new string[40];
- int index1 = 0;
- string str1 = InputManager.Fire1;
- strArray[index1] = str1;
- int index2 = 1;
- string str2 = InputManager.Fire2;
- strArray[index2] = str2;
- int index3 = 2;
- string str3 = InputManager.Fire3;
- strArray[index3] = str3;
- int index4 = 3;
- string str4 = InputManager.Back;
- strArray[index4] = str4;
- int index5 = 4;
- string str5 = InputManager.Inventory;
- strArray[index5] = str5;
- int index6 = 5;
- string str6 = InputManager.Character;
- strArray[index6] = str6;
- int index7 = 6;
- string str7 = InputManager.Journal;
- strArray[index7] = str7;
- int index8 = 7;
- string str8 = InputManager.SelectParty;
- strArray[index8] = str8;
- int index9 = 8;
- string str9 = InputManager.GroupMode;
- strArray[index9] = str9;
- int index10 = 9;
- string str10 = InputManager.RotateCameraLeft;
- strArray[index10] = str10;
- int index11 = 10;
- string str11 = InputManager.RotateCameraRight;
- strArray[index11] = str11;
- int index12 = 11;
- string str12 = InputManager.NextMob;
- strArray[index12] = str12;
- int index13 = 12;
- string str13 = InputManager.ShowGrid;
- strArray[index13] = str13;
- int index14 = 13;
- string str14 = InputManager.SwapWeapons;
- strArray[index14] = str14;
- int index15 = 14;
- string str15 = InputManager.AreaAttack;
- strArray[index15] = str15;
- int index16 = 15;
- string str16 = InputManager.HighlightAll;
- strArray[index16] = str16;
- int index17 = 16;
- string str17 = InputManager.ShowAttackRange;
- strArray[index17] = str17;
- int index18 = 17;
- string str18 = InputManager.Hotkey1;
- strArray[index18] = str18;
- int index19 = 18;
- string str19 = InputManager.Hotkey2;
- strArray[index19] = str19;
- int index20 = 19;
- string str20 = InputManager.Hotkey3;
- strArray[index20] = str20;
- int index21 = 20;
- string str21 = InputManager.Hotkey4;
- strArray[index21] = str21;
- int index22 = 21;
- string str22 = InputManager.Hotkey5;
- strArray[index22] = str22;
- int index23 = 22;
- string str23 = InputManager.Hotkey6;
- strArray[index23] = str23;
- int index24 = 23;
- string str24 = InputManager.EndTurn;
- strArray[index24] = str24;
- int index25 = 24;
- string str25 = InputManager.SelectPlayer1;
- strArray[index25] = str25;
- int index26 = 25;
- string str26 = InputManager.SelectPlayer2;
- strArray[index26] = str26;
- int index27 = 26;
- string str27 = InputManager.SelectPlayer3;
- strArray[index27] = str27;
- int index28 = 27;
- string str28 = InputManager.SelectPlayer4;
- strArray[index28] = str28;
- int index29 = 28;
- string str29 = InputManager.SelectPlayer5;
- strArray[index29] = str29;
- int index30 = 29;
- string str30 = InputManager.SelectPlayer6;
- strArray[index30] = str30;
- int index31 = 30;
- string str31 = InputManager.SelectPlayer7;
- strArray[index31] = str31;
- int index32 = 31;
- string str32 = InputManager.Map;
- strArray[index32] = str32;
- int index33 = 32;
- string str33 = InputManager.AttackTarget;
- strArray[index33] = str33;
- int index34 = 33;
- string str34 = InputManager.ChangeMoveMode;
- strArray[index34] = str34;
- int index35 = 34;
- string str35 = InputManager.Reload;
- strArray[index35] = str35;
- int index36 = 35;
- string str36 = InputManager.ResetCameraRotation;
- strArray[index36] = str36;
- int index37 = 36;
- string str37 = InputManager.RadioScan;
- strArray[index37] = str37;
- int index38 = 37;
- string str38 = InputManager.RadioAcknowledge;
- strArray[index38] = str38;
- int index39 = 38;
- string str39 = InputManager.QuickSave;
- strArray[index39] = str39;
- int index40 = 39;
- string str40 = InputManager.QuickLoad;
- strArray[index40] = str40;
- InputManager.buttonEvents = strArray;
- InputManager.layerIndex_Default = LayerMask.NameToLayer("Default");
- InputManager.layerIndex_TransparentFX = LayerMask.NameToLayer("TransparentFX");
- InputManager.layerIndex_IgnoreRaycast = LayerMask.NameToLayer("Ignore Raycast");
- InputManager.layerIndex_Water = LayerMask.NameToLayer("Water");
- InputManager.layerIndex_Terrain = LayerMask.NameToLayer("Terrain");
- InputManager.layerIndex_Mob = LayerMask.NameToLayer("Mob");
- InputManager.layerIndex_DynamicObject = LayerMask.NameToLayer("DynamicObject");
- InputManager.layerIndex_StaticMeshes = LayerMask.NameToLayer("StaticMeshes");
- InputManager.layerIndex_InventoryGUI = LayerMask.NameToLayer("InventoryGUI");
- InputManager.layerIndex_HUD = LayerMask.NameToLayer("HUD");
- InputManager.layerIndex_MiniMapIcon = LayerMask.NameToLayer("MiniMapIcon");
- InputManager.layerIndex_Floor = LayerMask.NameToLayer("Floor");
- InputManager.layerIndex_Wall = LayerMask.NameToLayer("Wall");
- InputManager.layerIndex_FadeOutOnly = LayerMask.NameToLayer("FadeOutOnly");
- InputManager.layerIndex_FadedFloor = LayerMask.NameToLayer("FadedFloor");
- InputManager.layerIndex_FadedWall = LayerMask.NameToLayer("FadedWall");
- InputManager.layerIndex_Cover = LayerMask.NameToLayer("Cover");
- InputManager.layerIndex_DressingRoom = LayerMask.NameToLayer("DressingRoom");
- InputManager.layerIndex_SpeechBubbles = LayerMask.NameToLayer("SpeechBubbles");
- InputManager.layerIndex_MovingObjects = LayerMask.NameToLayer("MovingObjects");
- InputManager.layerMask_Default = 1 << InputManager.layerIndex_Default;
- InputManager.layerMask_TransparentFX = 1 << InputManager.layerIndex_TransparentFX;
- InputManager.layerMask_IgnoreRaycast = 1 << InputManager.layerIndex_IgnoreRaycast;
- InputManager.layerMask_Water = 1 << InputManager.layerIndex_Water;
- InputManager.layerMask_Terrain = 1 << InputManager.layerIndex_Terrain;
- InputManager.layerMask_Mob = 1 << InputManager.layerIndex_Mob;
- InputManager.layerMask_DynamicObject = 1 << InputManager.layerIndex_DynamicObject;
- InputManager.layerMask_StaticMeshes = 1 << InputManager.layerIndex_StaticMeshes;
- InputManager.layerMask_InventoryGUI = 1 << InputManager.layerIndex_InventoryGUI;
- InputManager.layerMask_HUD = 1 << InputManager.layerIndex_HUD;
- InputManager.layerMask_MiniMapIcon = 1 << InputManager.layerIndex_MiniMapIcon;
- InputManager.layerMask_Floor = 1 << InputManager.layerIndex_Floor;
- InputManager.layerMask_Wall = 1 << InputManager.layerIndex_Wall;
- InputManager.layerMask_FadeOutOnly = 1 << InputManager.layerIndex_FadeOutOnly;
- InputManager.layerMask_FadedFloor = 1 << InputManager.layerIndex_FadedFloor;
- InputManager.layerMask_FadedWall = 1 << InputManager.layerIndex_FadedWall;
- InputManager.layerMask_Cover = 1 << InputManager.layerIndex_Cover;
- InputManager.layerMask_DressingRoom = 1 << InputManager.layerIndex_DressingRoom;
- InputManager.layerMask_SpeechBubbles = 1 << InputManager.layerIndex_SpeechBubbles;
- InputManager.layerMask_MovingObjects = 1 << InputManager.layerIndex_MovingObjects;
- InputManager.navMeshLayerIndex_Default = NavMesh.GetNavMeshLayerFromName("Default");
- InputManager.navMeshLayerIndex_Ladders = NavMesh.GetNavMeshLayerFromName("Ladders");
- InputManager.navMeshLayerIndex_Door = NavMesh.GetNavMeshLayerFromName("Door");
- }
- public void SetEdgeScrolling(bool scroll)
- {
- this.bEdgeScrolling = scroll;
- }
- [DebuggerHidden]
- public IEnumerable<PC> GetMovementPCs(PC pcPoint = null)
- {
- // ISSUE: object of a compiler-generated type is created
- // ISSUE: variable of a compiler-generated type
- InputManager.\u003CGetMovementPCs\u003Ec__Iterator8EE movementPcsCIterator8Ee = new InputManager.\u003CGetMovementPCs\u003Ec__Iterator8EE()
- {
- pcPoint = pcPoint,
- \u003C\u0024\u003EpcPoint = pcPoint,
- \u003C\u003Ef__this = this
- };
- int num = -2;
- // ISSUE: reference to a compiler-generated field
- movementPcsCIterator8Ee.\u0024PC = num;
- return (IEnumerable<PC>) movementPcsCIterator8Ee;
- }
- public void TogglePartyIsGrouped()
- {
- this.isPartyMovementGrouped = !this.isPartyMovementGrouped;
- PC pc = MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader;
- using (List<PC>.Enumerator enumerator = MonoBehaviourSingleton<Game>.GetInstance(false).party.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC current = enumerator.Current;
- if (this.selectedMobs.Contains((Mob) current))
- {
- if (!this.isPartyGrouped && (UnityEngine.Object) current != (UnityEngine.Object) pc)
- this.RemoveFromSelection((Mob) current, true);
- }
- else if (this.isPartyGrouped)
- this.AddToSelection((Mob) current);
- current.isSelected = this.isPartyGrouped || (UnityEngine.Object) current == (UnityEngine.Object) pc;
- }
- }
- MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader.MakeLeader();
- using (List<PC>.Enumerator enumerator = MonoBehaviourSingleton<Game>.GetInstance(false).party.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC current = enumerator.Current;
- current.ShowSelectedFX(current.isSelected);
- }
- }
- EventInfo_PartyGroupedChanged partyGroupedChanged = ObjectPool.Get<EventInfo_PartyGroupedChanged>();
- partyGroupedChanged.isPartyGrouped = this.isPartyMovementGrouped;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) partyGroupedChanged);
- }
- protected override void Init()
- {
- this.useGUILayout = false;
- MonoBehaviourSingleton<CursorManager>.GetInstance(false);
- this.SetCursorClipRect(true);
- }
- protected override void SceneStart()
- {
- this.moveClick = false;
- this.actionClick = false;
- this.formationDelay = 0.5f;
- this.navHit = new NavMeshHit();
- this.SetupFormation(ref this.formation, MonoBehaviourSingleton<FormationManager>.GetInstance(false).GetFormationTemplate("VIP"));
- this.SetupFormation(ref this.formationInstigate, MonoBehaviourSingleton<FormationManager>.GetInstance(false).GetFormationTemplate("Wedge"));
- GameObject gameObject1 = (GameObject) UnityEngine.Object.Instantiate((UnityEngine.Object) this.moveBlockedFxPrefab, Vector3.zero, Quaternion.identity);
- this.blockedCursor = gameObject1.GetComponent<BlockedCursor>();
- gameObject1.SetActive(false);
- GameObject gameObject2 = (GameObject) UnityEngine.Object.Instantiate((UnityEngine.Object) this.movePositionFxPrefab, Vector3.zero, Quaternion.identity);
- this.moveCursor = gameObject2.GetComponent<MoveCursor>();
- gameObject2.SetActive(false);
- this.bEdgeScrolling = PlayerPrefs.GetInt(OptionsMenu.EdgeScrolling, 0) == 1;
- }
- private void OnApplicationFocus(bool hasFocus)
- {
- if (!hasFocus)
- {
- Screen.showCursor = true;
- this.SetCursorClipRect(false);
- }
- if (!hasFocus)
- {
- if (!this.hasLostFocus)
- this.SetFreezeInput(true, "App Focus Lost");
- }
- else if (this.hasLostFocus)
- this.SetFreezeInput(false, "App Focus Gained");
- this.hasLostFocus = !hasFocus;
- }
- protected virtual void UpdateCamera()
- {
- if (Drama.isConversationOn || !this.freezeInput)
- {
- if (cInput.GetButtonDown("Fire3"))
- this.lastMiddleClickPosition = Input.mousePosition;
- if (cInput.GetButton("Fire3"))
- {
- this.cameraMove.z = Input.mousePosition.x - this.lastMiddleClickPosition.x;
- this.lastMiddleClickPosition = Input.mousePosition;
- }
- else
- this.cameraMove.z = 0.0f;
- }
- if (this.freezeInput)
- return;
- this.cameraMove.x = Input.GetAxisRaw("Horizontal");
- this.cameraMove.y = Input.GetAxisRaw("Vertical");
- if (!this.bEdgeScrolling)
- return;
- if ((double) Input.mousePosition.x >= (double) (Screen.width - 10))
- this.cameraMove.x = 1f;
- else if ((double) Input.mousePosition.x <= 10.0)
- this.cameraMove.x = -1f;
- if ((double) Input.mousePosition.y >= (double) (Screen.height - 10))
- {
- this.cameraMove.y = 1f;
- }
- else
- {
- if ((double) Input.mousePosition.y > 10.0)
- return;
- this.cameraMove.y = -1f;
- }
- }
- public bool OnButtonDown(string buttonName)
- {
- if (Drama.isConversationOn || !this.IsInputFrozen())
- {
- if (buttonName == InputManager.RotateCameraLeft)
- {
- this.cameraMove.w = -1f;
- return true;
- }
- else if (buttonName == InputManager.RotateCameraRight)
- {
- this.cameraMove.w = 1f;
- return true;
- }
- }
- if (this.IsInputFrozen() || MonoBehaviourSingleton<Game>.GetInstance(false).state != GameState.Gameplay && MonoBehaviourSingleton<Game>.GetInstance(false).state != GameState.RandomEncounter)
- return false;
- if (buttonName == InputManager.NextMob)
- {
- this.SelectNextMob(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift));
- return true;
- }
- else
- {
- if (buttonName == InputManager.ShowGrid)
- {
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat && MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn)
- {
- MonoBehaviourSingleton<CombatAStar>.GetInstance(false).ShowMap(!MonoBehaviourSingleton<CombatAStar>.GetInstance(false).gridOn);
- return true;
- }
- }
- else if (buttonName == InputManager.SwapWeapons)
- {
- using (List<Mob>.Enumerator enumerator = this.selectedMobs.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- Mob current = enumerator.Current;
- if (current is PC)
- {
- EventInfo_CommandSwapWeapons commandSwapWeapons = ObjectPool.Get<EventInfo_CommandSwapWeapons>();
- commandSwapWeapons.mob = current;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) commandSwapWeapons);
- }
- }
- }
- return true;
- }
- else if (buttonName == InputManager.AreaAttack)
- {
- if ((UnityEngine.Object) this.activePCs[0] != (UnityEngine.Object) null && (this.activePCs[0].stats.GetWeaponTemplate().weaponType == WeaponType.Thrown || this.activePCs[0].stats.GetWeaponTemplate().weaponType == WeaponType.RPG))
- UseASIManager.SetActiveASIName("aoeattack");
- else
- UseASIManager.SetActiveASIName("attack");
- return true;
- }
- else if (buttonName == InputManager.HighlightAll)
- {
- EventInfo_HighlightAll infoHighlightAll = ObjectPool.Get<EventInfo_HighlightAll>();
- infoHighlightAll.highlight = true;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) infoHighlightAll);
- return true;
- }
- else if (buttonName == InputManager.ShowAttackRange)
- {
- if (this.activePCs.Count > 0)
- this.activePCs[0].ShowAttackRangeFX(true, 2);
- return true;
- }
- else if (buttonName.StartsWith(InputManager.SelectPlayer))
- {
- string s = buttonName.Substring(InputManager.SelectPlayer.Length);
- int result = -1;
- if (int.TryParse(s, out result))
- {
- --result;
- if (result >= 0 && result < MonoBehaviourSingleton<Game>.GetInstance(false).party.Count)
- {
- PC pc1 = MonoBehaviourSingleton<Game>.GetInstance(false).party[result];
- bool flag = pc1.isSelected;
- if (!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift) && (!Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl)))
- this.ClearSelection(false);
- if (!pc1.isSelected)
- {
- PC pc2 = MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader;
- pc1.MakeLeader();
- this.AddToSelection((Mob) pc1);
- pc2.ShowSelectedFX(pc2.isSelected);
- if (flag && MonoBehaviourSingleton<HUD_Controller>.HasInstance())
- MonoBehaviourSingleton<HUD_Controller>.GetInstance(false).PartyMemberCenterCamera(pc1);
- }
- else
- this.RemoveFromSelection((Mob) pc1, true);
- }
- }
- return true;
- }
- else if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat && MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn && (buttonName == InputManager.EndTurn && this.activePCs.Count > 0) && this.activePCs[0].combatActionState == Mob.CombatActionState.THINKING)
- this.activePCs[0].combatActionState = Mob.CombatActionState.FINISHED;
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat && MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn && buttonName == InputManager.AttackTarget)
- {
- NPC selectedNpc = this.GetSelectedNPC();
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).GetCurrentMob() is PC && (UnityEngine.Object) selectedNpc != (UnityEngine.Object) null && selectedNpc.HatesParty())
- {
- PC pc = MonoBehaviourSingleton<CombatManager>.GetInstance(false).GetCurrentMob() as PC;
- bool flag = UseASIManager.GetActiveASIName() == "aoeattack";
- if (pc.inventory.equipment[7].template is ItemTemplate_WeaponAoe)
- flag = true;
- if (flag)
- {
- UseASIManager.SetActiveASIName((string) null);
- pc.UseAOEWeapon(MonoBehaviourSingleton<CursorManager>.GetInstance(false).arcAimPosition, MonoBehaviourSingleton<CursorManager>.GetInstance(false).spherePosition);
- }
- else
- {
- UseASIManager.SetActiveASIName((string) null);
- EventInfo_CommandAttack infoCommandAttack = ObjectPool.Get<EventInfo_CommandAttack>();
- infoCommandAttack.pc = pc;
- infoCommandAttack.target = (Targetable) selectedNpc;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) infoCommandAttack);
- MonoBehaviourSingleton<Game>.GetInstance(false).cameraController.FollowPC(pc);
- }
- }
- }
- else if (buttonName == InputManager.SpawnTestParty)
- {
- Game instance = MonoBehaviourSingleton<Game>.GetInstance(false);
- LevelInfo levelInfo = instance.GetLevelInfo();
- if (levelInfo.partyTemplates == null || levelInfo.partyTemplates.Length == 0)
- {
- InXile.LogWarning(LogChannel.Default, "No custom party to spawn. Add custom party templates to the level info.");
- return true;
- }
- else
- {
- for (int index = instance.party.Count - 1; index >= 0; --index)
- {
- PC pc = instance.party[index];
- pc.ai.Shutdown();
- UnityEngine.Object.Destroy((UnityEngine.Object) pc.gameObject);
- }
- instance.party.Clear();
- instance.partyTemplates = levelInfo.partyTemplates;
- instance.SpawnParty();
- }
- }
- return false;
- }
- }
- public bool OnButtonUp(string buttonName)
- {
- if (buttonName == InputManager.RotateCameraLeft && (double) this.cameraMove.w == -1.0)
- {
- this.cameraMove.w = 0.0f;
- return true;
- }
- else if (buttonName == InputManager.RotateCameraRight && (double) this.cameraMove.w == 1.0)
- {
- this.cameraMove.w = 0.0f;
- return true;
- }
- else
- {
- if (MonoBehaviourSingleton<Game>.GetInstance(false).state == GameState.Gameplay || MonoBehaviourSingleton<Game>.GetInstance(false).state == GameState.RandomEncounter)
- {
- if (buttonName == InputManager.HighlightAll)
- {
- EventInfo_HighlightAll infoHighlightAll = ObjectPool.Get<EventInfo_HighlightAll>();
- infoHighlightAll.highlight = false;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) infoHighlightAll);
- return true;
- }
- else if (buttonName == InputManager.ShowAttackRange)
- {
- if (this.activePCs.Count > 0 && PlayerPrefs.GetInt(OptionsMenu.DrawWeaponRanges) != 1)
- this.activePCs[0].ShowAttackRangeFX(false, 2);
- return true;
- }
- }
- return false;
- }
- }
- private void CheckInstigateDrama(RaycastHit hit, bool doubleClick)
- {
- Drama drama = (Drama) null;
- if ((bool) ((UnityEngine.Object) hit.transform.GetComponent<RaycastPropagate>()))
- {
- if ((UnityEngine.Object) hit.transform.GetComponent<RaycastPropagate>().target != (UnityEngine.Object) null)
- drama = hit.transform.GetComponent<RaycastPropagate>().target.GetComponent<Drama>();
- }
- else
- drama = hit.transform.GetComponent<Drama>();
- if ((UnityEngine.Object) drama != (UnityEngine.Object) null)
- {
- if (UseASIManager.IsSkillASI(UseASIManager.GetActiveASIName()) && CursorManager.ASIMatchesObject(drama.transform, MonoBehaviourSingleton<CursorManager>.GetInstance(false).GetCurrentCursor(), UseASIManager.GetActiveASIItem()))
- AudioManager.Play("Skill_Click_Matching");
- Drama.CheckInstigate(drama, this.GetFirstSelectedPlayer(), doubleClick);
- }
- else
- {
- SkillObject_Examine component = hit.transform.GetComponent<SkillObject_Examine>();
- if (!((UnityEngine.Object) component != (UnityEngine.Object) null) || component.difficulty != SkillLevelCategory.None)
- return;
- this.CheckExamineDrama(hit);
- }
- }
- private void CheckExamineDrama(RaycastHit hit)
- {
- Drama drama = (Drama) null;
- if ((bool) ((UnityEngine.Object) hit.transform.GetComponent<RaycastPropagate>()))
- {
- if ((UnityEngine.Object) hit.transform.GetComponent<RaycastPropagate>().target != (UnityEngine.Object) null)
- drama = hit.transform.GetComponent<RaycastPropagate>().target.GetComponent<Drama>();
- }
- else
- drama = hit.transform.GetComponent<Drama>();
- if ((UnityEngine.Object) drama != (UnityEngine.Object) null)
- {
- Drama.ExamineDrama(drama, MonoBehaviourSingleton<Game>.GetInstance(false).GetFirstSelectedPC(), hit);
- }
- else
- {
- GameObject gameObject = hit.transform.gameObject;
- if ((bool) ((UnityEngine.Object) hit.transform.GetComponent<RaycastPropagate>()) && (UnityEngine.Object) hit.transform.GetComponent<RaycastPropagate>().target != (UnityEngine.Object) null)
- gameObject = hit.transform.GetComponent<RaycastPropagate>().target.gameObject;
- Drama.ExamineDescriptionObject(gameObject, this.ClosestSelectedPC(hit.point));
- }
- }
- private void UpdateSelection()
- {
- if (cInput.GetButtonDown("Fire1") && !Drama.isConversationOn)
- {
- if (UseASIManager.GetActiveASIName() == "aoeattack")
- {
- InXile.Log(LogChannel.Input, "Blow that shit up! " + this.selectedMobs[0].name);
- UseASIManager.SetActiveASIName((string) null);
- (this.selectedMobs[0] as PC).UseAOEWeapon(MonoBehaviourSingleton<CursorManager>.GetInstance(false).arcAimPosition, MonoBehaviourSingleton<CursorManager>.GetInstance(false).spherePosition);
- }
- this.mouseDownPos = Input.mousePosition;
- this.wasMouseDownShift = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
- this.wasMouseDownCtrl = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
- this.pcLeaderOnDragStart = MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader;
- }
- else if (cInput.GetButtonUp("Fire1") && (UnityEngine.Object) Camera.main != (UnityEngine.Object) null)
- {
- if (this.actionClick)
- this.actionClick = false;
- else if ((double) (this.mouseDownPos - Input.mousePosition).sqrMagnitude > 16.0)
- {
- if ((UnityEngine.Object) this.pcLeaderOnDragStart != (UnityEngine.Object) null && !this.selectedMobs.Contains((Mob) this.pcLeaderOnDragStart))
- {
- float num = float.PositiveInfinity;
- PC pc = (PC) null;
- using (List<PC>.Enumerator enumerator = MonoBehaviourSingleton<Game>.GetInstance(false).party.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC current = enumerator.Current;
- if (this.selectedMobs.Contains((Mob) current))
- {
- Vector3 vector3 = Camera.main.WorldToViewportPoint(current.transform.position);
- vector3.x *= (float) Screen.width;
- vector3.y *= (float) Screen.height;
- float sqrMagnitude = (vector3 - this.mouseDownPos).sqrMagnitude;
- if ((double) sqrMagnitude < (double) num)
- {
- num = sqrMagnitude;
- pc = current;
- }
- }
- }
- }
- if ((UnityEngine.Object) pc != (UnityEngine.Object) null)
- {
- pc.MakeLeader();
- this.pcLeaderOnDragStart.ShowSelectedFX(this.pcLeaderOnDragStart.isSelected);
- }
- }
- this.pcLeaderOnDragStart = (PC) null;
- }
- else
- {
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hitInfo = new RaycastHit();
- int layerMask = ~(InputManager.layerMask_Terrain | InputManager.layerMask_FadeOutOnly | InputManager.layerMask_FadedFloor | InputManager.layerMask_FadedWall | InputManager.layerMask_IgnoreRaycast | InputManager.layerMask_TransparentFX | InputManager.layerMask_HUD | InputManager.layerMask_InventoryGUI);
- if (Physics.Raycast(ray, out hitInfo, float.PositiveInfinity, layerMask))
- {
- Mob component = hitInfo.transform.GetComponent<Mob>();
- if (!Drama.isConversationOn || Drama.IsPCInConversation(!(bool) ((UnityEngine.Object) component) ? (PC) null : component.asPartyPC))
- {
- if ((bool) ((UnityEngine.Object) component) && component.mobState != Mob.MobState.DEAD)
- {
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat)
- {
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn)
- {
- this.ClearSelection(true);
- if (component is PC)
- MonoBehaviourSingleton<Game>.GetInstance(false).cameraController.Snap(component.transform.position, false);
- else
- this.AddToSelection(component);
- }
- }
- else if (component is PC)
- {
- if (this.isPartyGrouped)
- {
- this.ClearSelection(false);
- (component as PC).MakeLeader();
- }
- else if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) || (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) || (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)))
- {
- if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
- {
- PC pc = MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader;
- (component as PC).MakeLeader();
- this.AddToSelection(component);
- pc.ShowSelectedFX(pc.isSelected);
- }
- else if ((component as PC).isSelected)
- {
- if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
- this.RemoveFromSelection(component, true);
- }
- else
- this.AddToSelection(component);
- }
- else
- {
- this.ClearSelection(false);
- (component as PC).MakeLeader();
- }
- }
- else
- {
- this.ClearSelection(true);
- this.AddToSelection(component);
- }
- }
- else
- this.ClearSelection(true);
- }
- }
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat || this.isPCSelected() || MonoBehaviourSingleton<Game>.GetInstance(false).party.Count <= 0)
- return;
- this.AddToSelection((Mob) MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader);
- }
- }
- else
- {
- if (!cInput.GetButton("Fire1") || Drama.isConversationOn || MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat || ((double) (this.mouseDownPos - Input.mousePosition).sqrMagnitude <= 16.0 || !this.selectionRectActive))
- return;
- this.ClearSelection(true);
- bool flag1 = false;
- Game instance = MonoBehaviourSingleton<Game>.GetInstance(false);
- Rect rect = this.MakeSelectionRect(this.mouseDownPos, Input.mousePosition);
- for (int index = 0; index < instance.party.Count; ++index)
- {
- PC pc = instance.party[index];
- Vector3 point = Camera.main.WorldToViewportPoint(pc.transform.position);
- point.x *= (float) Screen.width;
- point.y *= (float) Screen.height;
- if (rect.Contains(point))
- {
- bool flag2 = !this.wasMouseDownCtrl || pc.isLeader;
- flag1 = flag1 | pc.isSelected != flag2;
- pc.isSelected = flag2;
- if (flag2)
- {
- this.AddToSelection((Mob) pc);
- if (!this.activePCs.Contains(pc))
- this.activePCs.Add(pc);
- }
- else
- {
- this.RemoveFromSelection((Mob) pc, false);
- if (this.activePCs.Contains(pc))
- this.activePCs.Remove(pc);
- }
- }
- else if (!this.wasMouseDownShift && !this.wasMouseDownCtrl)
- {
- flag1 = flag1 | pc.isSelected;
- this.RemoveFromSelection((Mob) pc, false);
- if (this.activePCs.Contains(pc))
- this.activePCs.Remove(pc);
- }
- }
- if (!flag1)
- return;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) ObjectPool.Get<EventInfo_CharacterSelectionChanged>());
- }
- }
- private void Update()
- {
- if ((Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) && (double) Input.mousePosition.x >= 0.0 && ((double) Input.mousePosition.y >= 0.0 && (double) Input.mousePosition.x <= (double) Screen.width) && (double) Input.mousePosition.y <= (double) Screen.height)
- this.SetCursorClipRect(true);
- CombatManager instance1 = MonoBehaviourSingleton<CombatManager>.GetInstance(false);
- if (this.ignoreMousePosition && Input.mousePosition != this.ignoredMousePosition)
- this.ignoreMousePosition = false;
- if (MonoBehaviourSingleton<Game>.GetInstance(false).state != GameState.Gameplay && MonoBehaviourSingleton<Game>.GetInstance(false).state != GameState.RandomEncounter)
- return;
- this.UpdateCamera();
- if (this.freezeInput)
- {
- if (MonoBehaviourSingleton<GUIManager>.GetInstance(false).WillUseMouseClick())
- return;
- this.UpdateSelection();
- }
- else
- {
- bool flag1 = false;
- if (!MonoBehaviourSingleton<GUIManager>.GetInstance(false).WillUseMouseClick())
- {
- this.UpdateSelection();
- this.activePCs.Clear();
- if (instance1.inCombat)
- {
- Mob currentMob = instance1.GetCurrentMob();
- if ((bool) ((UnityEngine.Object) currentMob))
- {
- PC asPartyPc = currentMob.asPartyPC;
- if ((bool) ((UnityEngine.Object) asPartyPc))
- this.activePCs.Add(asPartyPc);
- }
- }
- else
- {
- using (List<Mob>.Enumerator enumerator = this.selectedMobs.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC asPartyPc = enumerator.Current.asPartyPC;
- if ((UnityEngine.Object) asPartyPc != (UnityEngine.Object) null)
- this.activePCs.Add(asPartyPc);
- }
- }
- if (this.activePCs.Count == 0)
- this.activePCs.Add(MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader);
- }
- if (cInput.GetButtonDown("Fire1") && (UnityEngine.Object) Camera.main != (UnityEngine.Object) null)
- {
- int layerMask = InputManager.layerMask_Terrain | InputManager.layerMask_Floor | InputManager.layerMask_Mob | InputManager.layerMask_DynamicObject | InputManager.layerMask_Wall | InputManager.layerMask_Cover;
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hitInfo = new RaycastHit();
- if (Physics.Raycast(ray, out hitInfo, 100f, layerMask) && (bool) ((UnityEngine.Object) hitInfo.transform))
- {
- AnalyticsManager instance2 = MonoBehaviourSingleton<AnalyticsManager>.GetInstance(false);
- string evt = !this.didDoubleLeftClick ? "Left Click" : " Left Double-Click";
- string levelNameCurrent = MonoBehaviourSingleton<Game>.GetInstance(false).levelNameCurrent;
- string[] strArray = new string[3];
- int index1 = 0;
- string str1 = hitInfo.transform.position.x.ToString();
- strArray[index1] = str1;
- int index2 = 1;
- string str2 = hitInfo.transform.position.y.ToString();
- strArray[index2] = str2;
- int index3 = 2;
- string str3 = this.clickPosition.z.ToString();
- strArray[index3] = str3;
- instance2.LogApTrak(evt, levelNameCurrent, strArray);
- bool flag2 = false;
- string activeAsiName = UseASIManager.GetActiveASIName();
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat)
- {
- PC pc = MonoBehaviourSingleton<CombatManager>.GetInstance(false).GetCurrentMob() as PC;
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn && (UnityEngine.Object) pc != (UnityEngine.Object) null)
- flag2 = pc.combatActionState == Mob.CombatActionState.THINKING;
- }
- else if (activeAsiName == "attack")
- flag2 = true;
- bool flag3 = MonoBehaviourSingleton<CursorManager>.GetInstance(false).GetCurrentCursor() == CursorManager.Cursors.Reload || MonoBehaviourSingleton<CursorManager>.GetInstance(false).GetCurrentCursor() == CursorManager.Cursors.CantReload;
- if ((!MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat || flag2) && (activeAsiName == "attack" || flag3))
- {
- UseASIManager.SetActiveASIName((string) null);
- Targetable targetable = !(bool) ((UnityEngine.Object) hitInfo.transform.GetComponent<RaycastPropagate>()) ? hitInfo.transform.GetComponent<Targetable>() : hitInfo.transform.GetComponent<RaycastPropagate>().target.GetComponent<Targetable>();
- if ((UnityEngine.Object) targetable != (UnityEngine.Object) null && (double) targetable.curHP > 0.0 && !(targetable is PC))
- {
- foreach (PC pc in this.GetMovementPCs((PC) null))
- {
- if (pc.IsOutOfAmmo())
- {
- if (pc.CanReload())
- {
- EventInfo_CommandReload infoCommandReload = ObjectPool.Get<EventInfo_CommandReload>();
- infoCommandReload.mob = (Mob) pc;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) infoCommandReload);
- }
- }
- else if ((UnityEngine.Object) pc != (UnityEngine.Object) targetable)
- {
- bool flag4 = false;
- if ((UnityEngine.Object) this.SelectedLeaderPC() == (UnityEngine.Object) pc)
- flag4 = true;
- EventInfo_CommandAttack infoCommandAttack = ObjectPool.Get<EventInfo_CommandAttack>();
- infoCommandAttack.pc = pc;
- infoCommandAttack.target = targetable;
- infoCommandAttack.meleeMoveToRange = flag4;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) infoCommandAttack);
- MonoBehaviourSingleton<Game>.GetInstance(false).cameraController.FollowPC(pc);
- this.actionClick = true;
- }
- }
- }
- }
- else if (UseASIManager.GetActiveASIName() == "useItem" && (UnityEngine.Object) UseASIManager.GetActiveASIItem() != (UnityEngine.Object) null && UseASIManager.GetActiveASIItem() is ItemInstance_Usable)
- {
- Transform t = hitInfo.transform;
- RaycastPropagate component1 = hitInfo.transform.GetComponent<RaycastPropagate>();
- if ((UnityEngine.Object) component1 != (UnityEngine.Object) null)
- t = component1.target;
- Targetable component2 = t.GetComponent<Targetable>();
- Drama component3 = t.GetComponent<Drama>();
- Vector3 position = t.position;
- Vector3 vector3 = t.position;
- float num = 1.6f;
- if ((UnityEngine.Object) component3 != (UnityEngine.Object) null)
- num = component3.instigateDistance;
- List<Transform> list = new List<Transform>();
- Drama.FindInstigatePointChildren(t, ref list);
- Transform transform = Drama.PickBestInstigatePoint(ref list, UseASIManager.GetActiveASIItemOwner().transform);
- if ((UnityEngine.Object) transform != (UnityEngine.Object) null)
- {
- position = transform.position;
- num = 0.5f;
- vector3 = position + transform.forward * 10f;
- }
- EventInfo_CommandUseItem infoCommandUseItem = ObjectPool.Get<EventInfo_CommandUseItem>();
- infoCommandUseItem.destination = position;
- infoCommandUseItem.mob = (Mob) UseASIManager.GetActiveASIItemOwner();
- infoCommandUseItem.item = UseASIManager.GetActiveASIItem() as ItemInstance_Usable;
- infoCommandUseItem.lookAt = vector3;
- infoCommandUseItem.doubleClicked = this.didDoubleLeftClick;
- Vector3 nearestEdge;
- if ((UnityEngine.Object) component2 != (UnityEngine.Object) null)
- {
- if ((bool) ((UnityEngine.Object) t.GetComponent<TargetableObject>()) && (UnityEngine.Object) transform == (UnityEngine.Object) null)
- nearestEdge = t.GetComponent<TargetableObject>().GetNearestEdge(UseASIManager.GetActiveASIItemOwner().transform.position);
- infoCommandUseItem.target = component2;
- infoCommandUseItem.targetDrama = (Drama) null;
- infoCommandUseItem.distance = num;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) infoCommandUseItem);
- UseASIManager.SetActiveASIName((string) null);
- UseASIManager.SetActiveASIItem((ItemInstance) null, (PC) null);
- }
- else if ((bool) ((UnityEngine.Object) component3))
- {
- if ((bool) ((UnityEngine.Object) t.GetComponent<TargetableObject>()) && (UnityEngine.Object) transform == (UnityEngine.Object) null)
- nearestEdge = t.GetComponent<TargetableObject>().GetNearestEdge(UseASIManager.GetActiveASIItemOwner().transform.position);
- infoCommandUseItem.target = (Targetable) null;
- infoCommandUseItem.targetDrama = component3;
- infoCommandUseItem.distance = num;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) infoCommandUseItem);
- UseASIManager.SetActiveASIName((string) null);
- UseASIManager.SetActiveASIItem((ItemInstance) null, (PC) null);
- }
- else if ((UseASIManager.GetActiveASIItem().template as ItemTemplate_Usable).usableOnWorld)
- {
- infoCommandUseItem.target = (Targetable) null;
- infoCommandUseItem.distance = num;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) infoCommandUseItem);
- UseASIManager.SetActiveASIName((string) null);
- UseASIManager.SetActiveASIItem((ItemInstance) null, (PC) null);
- }
- MonoBehaviourSingleton<GlobalFxHandler>.GetInstance(false).InventoryItemOnSelectTarget();
- this.actionClick = true;
- }
- else if (UseASIManager.GetActiveASIName() != null)
- {
- this.CheckInstigateDrama(hitInfo, this.didDoubleLeftClick);
- this.actionClick = true;
- }
- else if (!(bool) ((UnityEngine.Object) hitInfo.transform.GetComponent<PC>()) || hitInfo.transform.GetComponent<PC>().mobState == Mob.MobState.DEAD)
- this.CheckInstigateDrama(hitInfo, this.didDoubleLeftClick);
- }
- }
- else if (cInput.GetButton("Fire2"))
- {
- if (cInput.GetButtonDown("Fire2") && MonoBehaviourSingleton<CursorManager>.GetInstance(false).UsingASI && UseASIManager.GetActiveASIName() != "attack")
- {
- this.moveClick = false;
- UseASIManager.SetActiveASIName((string) null);
- }
- else if (cInput.GetButtonDown("Fire2") && (bool) ((UnityEngine.Object) Camera.main))
- {
- this.moveClick = false;
- if (this.activePCs.Count > 0)
- {
- int layerMask = InputManager.layerMask_Terrain | InputManager.layerMask_Floor | InputManager.layerMask_Mob | InputManager.layerMask_DynamicObject | InputManager.layerMask_Wall;
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hitInfo = new RaycastHit();
- if (Physics.Raycast(ray, out hitInfo, 100f, layerMask) && (bool) ((UnityEngine.Object) hitInfo.transform))
- {
- this.clickPosition = hitInfo.point;
- if (hitInfo.collider.transform.gameObject.layer == InputManager.layerIndex_Terrain || hitInfo.collider.transform.gameObject.layer == InputManager.layerIndex_Floor)
- {
- if (MonoBehaviourSingleton<CursorManager>.GetInstance(false).UsingASI)
- {
- this.moveClick = false;
- UseASIManager.SetActiveASIName((string) null);
- }
- else
- {
- this.moveClick = true;
- if (!MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat)
- {
- this.formationTimer = Time.time;
- this.formation.Rotate(this.clickPosition + this.clickPosition - this.activePCs[0].transform.position, this.clickPosition);
- this.formation.transform.position = this.clickPosition + new Vector3(0.0f, 0.1f, 0.0f);
- }
- }
- }
- else if (hitInfo.transform.gameObject.layer == InputManager.layerIndex_Mob)
- {
- if (!MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat || MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn)
- {
- Mob component = hitInfo.transform.gameObject.GetComponent<Mob>();
- if (component is NPC)
- {
- if (!this.IsSelected(component))
- {
- this.ClearSelection(true);
- this.AddToSelection(component);
- }
- else
- this.RemoveFromSelection(component, true);
- this.CheckExamineDrama(hitInfo);
- }
- else if (this.IsSelected(component) && this.GetNumSelectedPCs() > 1 && (UnityEngine.Object) MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader != (UnityEngine.Object) component)
- this.RemoveFromSelection(component, true);
- }
- }
- else if (hitInfo.transform.gameObject.layer == InputManager.layerIndex_DynamicObject)
- this.CheckExamineDrama(hitInfo);
- }
- }
- }
- RaycastHit hitInfo1;
- if (this.formationSpinning && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo1) && (double) Vector3.Distance(hitInfo1.point, this.clickPosition) > 0.5)
- this.formation.Rotate(hitInfo1.point, this.clickPosition);
- if (this.activePCs.Count > 1 && (double) this.formationTimer != -1.0 && (!this.formationSpinning && (double) Time.time - (double) this.formationTimer > (double) this.formationDelay))
- {
- if (!this.formationSpinning)
- this.formationTimer = -1f;
- RaycastHit hitInfo2;
- if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo2))
- {
- this.formationSpinning = true;
- this.formation.gameObject.SetActive(true);
- this.formation.ActivatePositions(this.activePCs.Count);
- }
- }
- }
- if (this.moveClick && cInput.GetButtonUp("Fire2") && ((bool) ((UnityEngine.Object) Camera.main) && UseASIManager.GetActiveASIName() == null))
- {
- this.moveClick = false;
- if (this.activePCs.Count > 0)
- {
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat && this.lastCombatSquare != null && (MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn && this.activePCs[0].combatActionState == Mob.CombatActionState.THINKING))
- {
- if (MonoBehaviourSingleton<CombatAStar>.GetInstance(false).Search(this.activePCs[0].currentSquare, this.lastCombatSquare, true, this.activePCs[0].combatActionPointsRemaining, this.activePCs[0].stats.GetCombatSpeed()).Count > 0)
- {
- int pathCost = MonoBehaviourSingleton<CombatAStar>.GetInstance(false).GetPathCost(this.activePCs[0].stats.GetCombatSpeed());
- if (pathCost > 0)
- {
- MonoBehaviourSingleton<CombatAStar>.GetInstance(false).DrawSmoothPath(this.activePCs[0].pathOrigin.transform, this.activePCs[0].stats.GetCombatSpeed());
- MonoBehaviourSingleton<GlobalFxHandler>.GetInstance(false).Combat_OnMove();
- EventInfo_CommandMove eventInfoCommandMove = ObjectPool.Get<EventInfo_CommandMove>();
- eventInfoCommandMove.mob = (Mob) this.activePCs[0];
- eventInfoCommandMove.path = MonoBehaviourSingleton<CombatAStar>.GetInstance(false).VectorSmoothPath();
- eventInfoCommandMove.actionPointCost = pathCost;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) eventInfoCommandMove);
- MonoBehaviourSingleton<Game>.GetInstance(false).cameraController.FollowPC(this.activePCs[0]);
- this.lastCombatSquare = (CombatAStarNode) null;
- this.timerCombatSquare = (CombatAStarNode) null;
- }
- else
- MonoBehaviourSingleton<CombatAStar>.GetInstance(false).ClearPath(this.activePCs[0].pathOrigin.transform);
- }
- else
- MonoBehaviourSingleton<CombatAStar>.GetInstance(false).ClearPath(this.activePCs[0].pathOrigin.transform);
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).RemoveText(this.cursorTextId);
- this.cursorTextId = -1;
- }
- else if (!MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat && this.activePCs.Count > 0)
- {
- bool flag2 = !NavMesh.SamplePosition(this.clickPosition, out this.navHit, 10f, 1 << NavMesh.GetNavMeshLayerFromName("Default") | 1 << NavMesh.GetNavMeshLayerFromName("Terrain"));
- if (!flag2 && (double) Vector2.Distance(new Vector2(this.navHit.position.x, this.navHit.position.z), new Vector2(this.clickPosition.x, this.clickPosition.z)) > 0.800000011920929)
- flag2 = true;
- if (flag2)
- {
- this.blockedCursor.ShowAt(this.clickPosition + Vector3.up * 0.05f);
- }
- else
- {
- AnalyticsManager instance2 = MonoBehaviourSingleton<AnalyticsManager>.GetInstance(false);
- string evt = !this.didDoubleLeftClick ? "Move Click" : " Move Double-Click";
- string levelNameCurrent = MonoBehaviourSingleton<Game>.GetInstance(false).levelNameCurrent;
- string[] strArray = new string[3];
- int index1 = 0;
- string str1 = this.clickPosition.x.ToString();
- strArray[index1] = str1;
- int index2 = 1;
- string str2 = this.clickPosition.y.ToString();
- strArray[index2] = str2;
- int index3 = 2;
- string str3 = this.clickPosition.z.ToString();
- strArray[index3] = str3;
- instance2.LogApTrak(evt, levelNameCurrent, strArray);
- this.moveCursor.ShowAt(this.clickPosition + Vector3.up * 0.05f);
- MonoBehaviourSingleton<Game>.GetInstance(false).cameraController.FollowPC(this.activePCs[0]);
- if (this.movementPCsCount > 1)
- {
- this.MoveInFormation(this.formation, this.clickPosition, this.didDoubleRightClick, (PC) null, 0.0f);
- }
- else
- {
- EventInfo_CommandMove eventInfoCommandMove = ObjectPool.Get<EventInfo_CommandMove>();
- eventInfoCommandMove.mob = (Mob) this.activePCs[0];
- eventInfoCommandMove.destination = this.clickPosition;
- eventInfoCommandMove.sprint = this.didDoubleRightClick;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) eventInfoCommandMove);
- }
- }
- }
- this.formationTimer = -1f;
- this.formationSpinning = false;
- if ((UnityEngine.Object) this.formation != (UnityEngine.Object) null)
- this.formation.gameObject.SetActive(false);
- }
- }
- if (cInput.GetButtonUp("Fire2"))
- this.rightClickUpTime = Time.time;
- if (cInput.GetButtonUp("Fire1"))
- this.leftClickUpTime = Time.time;
- if ((!this.holdForCombatPath || cInput.GetButton("Fire2")) && (!this.ignoreMousePosition && MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat) && (MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn && this.activePCs.Count > 0 && (this.activePCs[0].combatActionState == Mob.CombatActionState.THINKING && UseASIManager.GetActiveASIName() == null)))
- {
- PC pc = this.activePCs[0];
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hitInfo = new RaycastHit();
- if (Physics.Raycast(ray, out hitInfo, 1000f, this.layerMaskCombatPath) && (bool) ((UnityEngine.Object) hitInfo.transform) && (hitInfo.transform.gameObject.layer == InputManager.layerIndex_Terrain || hitInfo.transform.gameObject.layer == InputManager.layerIndex_Floor))
- {
- this.mouseoverSquare = MonoBehaviourSingleton<CombatAStar>.GetInstance(false).GetNode(hitInfo.point, hitInfo.transform.gameObject);
- if (this.mouseoverSquare != null && MonoBehaviourSingleton<CombatAStar>.GetInstance(false).IsNodeOpen(this.mouseoverSquare))
- {
- flag1 = true;
- if (this.timerCombatSquare != this.mouseoverSquare)
- {
- this.timerCombatSquare = this.mouseoverSquare;
- this.combatSquareTimer = Time.time;
- }
- if ((double) Time.time - (double) this.combatSquareTimer > 0.200000002980232 && this.lastCombatSquare != this.mouseoverSquare)
- {
- this.lastCombatSquare = this.mouseoverSquare;
- if (MonoBehaviourSingleton<CombatAStar>.GetInstance(false).Search(pc.transform.position, hitInfo.point, true, pc.combatActionPointsRemaining, pc.stats.GetCombatSpeed()).Count > 0)
- {
- MonoBehaviourSingleton<CombatAStar>.GetInstance(false).DrawSmoothPath(pc.pathOrigin.transform, pc.stats.GetCombatSpeed());
- pc.pathOrigin.SetActive(true);
- int pathCost = MonoBehaviourSingleton<CombatAStar>.GetInstance(false).GetPathCost(pc.stats.GetCombatSpeed());
- if (pathCost != -1 && pathCost <= pc.combatActionPointsRemaining)
- {
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).ClearCursor((Transform) null);
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).RemoveText(this.cursorTextId);
- this.cursorTextId = MonoBehaviourSingleton<CursorManager>.GetInstance(false).AddText(this.cursorTextId, (string) (object) pathCost + (object) " " + Language.Localize("<@>AP"), MonoBehaviourSingleton<GUIManager>.GetInstance(false).largeText, Color.green, false);
- }
- }
- else
- {
- MonoBehaviourSingleton<CombatAStar>.GetInstance(false).DrawInvalidPath(this.mouseoverSquare, pc.pathOrigin.transform);
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).RemoveText(this.cursorTextId);
- this.cursorTextId = -1;
- }
- }
- }
- }
- }
- else if (!MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat && !this.moveClick && (bool) ((UnityEngine.Object) Camera.main))
- {
- bool flag2 = true;
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hitInfo = new RaycastHit();
- if (Physics.Raycast(ray, out hitInfo, 1000f, InputManager.layerMask_Terrain | InputManager.layerMask_Floor) && (bool) ((UnityEngine.Object) hitInfo.transform))
- {
- NavMeshHit hit;
- NavMesh.SamplePosition(hitInfo.point, out hit, 1f, 1);
- if ((double) Vector3.Distance(hitInfo.point, hit.position) > 1.0)
- flag2 = false;
- }
- else
- flag2 = false;
- if (!flag2 && MonoBehaviourSingleton<CursorManager>.GetInstance(false).GetCurrentCursor() == CursorManager.Cursors.Default)
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).SetCursor(CursorManager.Cursors.InvalidTerrain, false);
- else if (flag2 && MonoBehaviourSingleton<CursorManager>.GetInstance(false).GetCurrentCursor() == CursorManager.Cursors.InvalidTerrain)
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).SetCursor(CursorManager.Cursors.Default, false);
- }
- }
- else if (MonoBehaviourSingleton<CursorManager>.GetInstance(false).GetCurrentCursor() == CursorManager.Cursors.InvalidTerrain)
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).SetCursor(CursorManager.Cursors.Default, false);
- if (flag1 || this.lastCombatSquare == null)
- return;
- this.lastCombatSquare = (CombatAStarNode) null;
- if (this.activePCs.Count > 0)
- MonoBehaviourSingleton<CombatAStar>.GetInstance(false).ClearPath(this.activePCs[0].pathOrigin.transform);
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).RemoveText(this.cursorTextId);
- this.cursorTextId = -1;
- if (!this.ignoreMousePosition || !MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat || !MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn)
- return;
- PC pc1 = MonoBehaviourSingleton<CombatManager>.GetInstance(false).GetCurrentMob() as PC;
- NPC selectedNpc = this.GetSelectedNPC();
- if (!((ItemTemplate) (pc1.stats.GetWeaponTemplate() as ItemTemplate_WeaponAoe) != (ItemTemplate) null) || !((UnityEngine.Object) selectedNpc != (UnityEngine.Object) null))
- return;
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).ShowSphere();
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).SetSpherePosition(selectedNpc.transform.position);
- }
- }
- public void MoveInFormation(FormationTemplate formation, Vector3 destination, bool sprint = false, PC pcPoint = null, float distCloseEnough = 0.0f)
- {
- float num1 = this.distFollowHangBack * this.distFollowHangBack;
- float num2 = this.distToFormationMax * this.distToFormationMax;
- List<Mob> mobs = new List<Mob>();
- int i = 0;
- PC pc1 = !((UnityEngine.Object) pcPoint != (UnityEngine.Object) null) ? this.activePCs[0] : pcPoint;
- formation.Rotate(destination + destination - pc1.transform.position, destination);
- if ((double) distCloseEnough > 0.0)
- destination += (pc1.transform.position - destination).normalized * distCloseEnough;
- Vector3 dest = destination;
- if ((UnityEngine.Object) pcPoint != (UnityEngine.Object) null)
- {
- Vector3 vector3_1 = new Vector3(0.0f, 0.0f, 0.0f);
- int num3 = 0;
- foreach (PC pc2 in this.GetMovementPCs(pcPoint))
- {
- if ((UnityEngine.Object) pc2 != (UnityEngine.Object) pcPoint)
- {
- vector3_1 += pc2.transform.position;
- ++num3;
- }
- }
- if (num3 > 0)
- {
- Vector3 vector3_2 = vector3_1 / (float) num3;
- dest = (double) (destination - vector3_2).sqrMagnitude <= (double) num1 ? vector3_2 : destination - (destination - vector3_2).normalized * this.distFollowHangBack;
- formation.transform.position = vector3_2;
- formation.Rotate(destination, dest);
- }
- }
- formation.transform.position = dest + new Vector3(0.0f, 0.1f, 0.0f);
- foreach (PC pc2 in this.GetMovementPCs(MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader))
- {
- if (!((UnityEngine.Object) pcPoint != (UnityEngine.Object) null) || !((UnityEngine.Object) pc2 != (UnityEngine.Object) pcPoint) || (double) (formation.Pos(i) - pc2.transform.position).sqrMagnitude >= (double) num2)
- {
- pc2.sortKey = (MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader.transform.position - pc2.transform.position).sqrMagnitude;
- pc2.indexSorted = i;
- mobs.Add((Mob) pc2);
- if ((UnityEngine.Object) pcPoint != (UnityEngine.Object) pc2)
- ++i;
- }
- }
- Mob.SortBySortKey(mobs, false);
- float time = Time.time;
- float num4 = time;
- int index = (int) MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader.moveMode;
- float max = this.rangeMoveStartDelay;
- using (List<Mob>.Enumerator enumerator = mobs.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- Mob current = enumerator.Current;
- EventInfo_CommandMove eventInfoCommandMove = ObjectPool.Get<EventInfo_CommandMove>();
- eventInfoCommandMove.mob = current;
- eventInfoCommandMove.destination = !((UnityEngine.Object) current == (UnityEngine.Object) pcPoint) ? formation.Pos(current.indexSorted) : destination;
- eventInfoCommandMove.sprint = sprint;
- eventInfoCommandMove.timeActivate = num4;
- eventInfoCommandMove.dontClearStack = (UnityEngine.Object) pcPoint == (UnityEngine.Object) current;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) eventInfoCommandMove);
- if ((double) current.navMeshAgent.velocity.magnitude <= 0.300000011920929)
- num4 = time + (this.baseMoveStartDelay + UnityEngine.Random.Range(0.0f, max)) * this.MoveStartDelayScaleOfMoveMode[index];
- }
- }
- }
- public void OnGUI()
- {
- if (MonoBehaviourSingleton<Game>.GetInstance(false).state != GameState.Gameplay && MonoBehaviourSingleton<Game>.GetInstance(false).state != GameState.RandomEncounter || (MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat || MonoBehaviourSingleton<GUIManager>.GetInstance(false).WillUseMouseClick()) || (this.freezeInput || !Input.GetMouseButton(0) || (Input.GetMouseButtonDown(0) || cInput.GetButtonDown(InputManager.Fire1))) || ((double) (this.mouseDownPos - Input.mousePosition).sqrMagnitude <= 16.0 || !this.selectionRectActive))
- return;
- Rect rect = this.MakeSelectionRect(this.mouseDownPos, Input.mousePosition);
- Rect position = rect;
- position.yMin = (float) Screen.height - rect.yMax;
- position.yMax = (float) Screen.height - rect.yMin;
- GUI.color = new Color(1f, 1f, 1f, 0.5f);
- GUI.Box(position, string.Empty, this.selectionRectStyle);
- }
- public void ClearSelectedMobs()
- {
- this.selectedMobs.Clear();
- }
- public void ClearSelection(bool DontClearPCs = false)
- {
- bool flag1 = false;
- bool flag2 = false;
- for (int index = this.selectedMobs.Count - 1; index >= 0; --index)
- {
- Mob mob = this.selectedMobs[index];
- if (!(mob is PC) || !DontClearPCs)
- {
- mob.ShowSelectedFX(0 != 0 || mob is PC && (mob as PC).shouldShowAsLeader);
- this.selectedMobs.RemoveAt(index);
- if ((UnityEngine.Object) mob.asPartyPC != (UnityEngine.Object) null)
- {
- ((PC) mob).isSelected = false;
- flag2 = true;
- }
- else if (mob.GetType() == typeof (NPC))
- flag1 = true;
- }
- }
- if (flag2)
- {
- using (List<PC>.Enumerator enumerator = MonoBehaviourSingleton<Game>.GetInstance(false).party.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC current = enumerator.Current;
- current.ShowSelectedFX(current.isSelected);
- }
- }
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) ObjectPool.Get<EventInfo_CharacterSelectionChanged>());
- }
- if (!flag1)
- return;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) ObjectPool.Get<EventInfo_NPCSelectedRemoved>());
- }
- public void AddToSelection(Mob m)
- {
- m.ShowSelectedFX(true);
- if (!this.selectedMobs.Contains(m))
- this.selectedMobs.Add(m);
- if (m is PC)
- {
- ((PC) m).isSelected = true;
- using (List<PC>.Enumerator enumerator = MonoBehaviourSingleton<Game>.GetInstance(false).party.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC current = enumerator.Current;
- current.ShowSelectedFX(current.isSelected || current.shouldShowAsLeader);
- }
- }
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) ObjectPool.Get<EventInfo_CharacterSelectionChanged>());
- }
- else
- {
- EventInfo_NPCSelected eventInfoNpcSelected = ObjectPool.Get<EventInfo_NPCSelected>();
- eventInfoNpcSelected.target = m;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) eventInfoNpcSelected);
- }
- }
- public void RemoveFromSelection(Mob m, bool publishEvents = true)
- {
- m.ShowSelectedFX(false);
- this.selectedMobs.Remove(m);
- if ((UnityEngine.Object) m.asPartyPC != (UnityEngine.Object) null)
- {
- ((PC) m).isSelected = this.isPartyGrouped;
- using (List<PC>.Enumerator enumerator = MonoBehaviourSingleton<Game>.GetInstance(false).party.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC current = enumerator.Current;
- current.ShowSelectedFX(current.isSelected || current.shouldShowAsLeader);
- }
- }
- if (!publishEvents)
- return;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) ObjectPool.Get<EventInfo_CharacterSelectionChanged>());
- }
- else
- {
- if (!publishEvents)
- return;
- MonoBehaviourSingleton<EventManager>.GetInstance(false).Publish((EventInfoBase) ObjectPool.Get<EventInfo_NPCSelectedRemoved>());
- }
- }
- public bool IsSelected(Mob m)
- {
- // ISSUE: object of a compiler-generated type is created
- // ISSUE: reference to a compiler-generated method
- return (UnityEngine.Object) null != (UnityEngine.Object) this.selectedMobs.Find(new Predicate<Mob>(new InputManager.\u003CIsSelected\u003Ec__AnonStorey9BA()
- {
- m = m
- }.\u003C\u003Em__218));
- }
- public bool isPCSelected()
- {
- using (List<Mob>.Enumerator enumerator = this.selectedMobs.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- if ((bool) ((UnityEngine.Object) (enumerator.Current as PC)))
- return true;
- }
- }
- return false;
- }
- public int GetNumSelectedPCs()
- {
- int num = 0;
- using (List<Mob>.Enumerator enumerator = this.selectedMobs.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- if (enumerator.Current is PC)
- ++num;
- }
- }
- return num;
- }
- public bool isNPCSelected()
- {
- for (int index = 0; index < this.selectedMobs.Count; ++index)
- {
- if (this.selectedMobs[index] is NPC)
- return true;
- }
- return false;
- }
- public NPC GetSelectedNPC()
- {
- for (int index = 0; index < this.selectedMobs.Count; ++index)
- {
- if (this.selectedMobs[index] is NPC)
- return this.selectedMobs[index] as NPC;
- }
- return (NPC) null;
- }
- private void SelectNextMob(bool reverse = false)
- {
- bool flag = false;
- Mob m = (Mob) null;
- if (MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat && MonoBehaviourSingleton<CombatManager>.GetInstance(false).isPlayersTurn)
- {
- List<NPC> list = new List<NPC>();
- using (List<Mob>.Enumerator enumerator = MonoBehaviourSingleton<CombatManager>.GetInstance(false).mobs.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- Mob current = enumerator.Current;
- if (current is NPC && current.mobState != Mob.MobState.DEAD && (current.HatesParty() && MonoBehaviourSingleton<CombatManager>.GetInstance(false).GetCurrentMob().IsPositionVisible(current.transform.position, true, true)))
- list.Add(current as NPC);
- }
- }
- if (reverse)
- list.Reverse();
- NPC selectedNpc1 = this.GetSelectedNPC();
- using (List<NPC>.Enumerator enumerator = list.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- NPC current = enumerator.Current;
- if ((UnityEngine.Object) m == (UnityEngine.Object) null)
- m = (Mob) current;
- if (flag || (UnityEngine.Object) selectedNpc1 == (UnityEngine.Object) null)
- {
- this.AddToSelection((Mob) current);
- flag = false;
- break;
- }
- else if ((UnityEngine.Object) selectedNpc1 == (UnityEngine.Object) current)
- {
- this.RemoveFromSelection((Mob) current, true);
- flag = true;
- }
- }
- }
- if ((flag || this.selectedMobs.Count == 0) && (UnityEngine.Object) m != (UnityEngine.Object) null)
- this.AddToSelection(m);
- NPC selectedNpc2 = this.GetSelectedNPC();
- if ((UnityEngine.Object) selectedNpc2 != (UnityEngine.Object) null && (UnityEngine.Object) this.GetFirstSelectedPlayer() != (UnityEngine.Object) null && this.GetFirstSelectedPlayer().stats.GetWeaponTemplate() is ItemTemplate_WeaponAoe)
- {
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).ShowSphere();
- MonoBehaviourSingleton<CursorManager>.GetInstance(false).SetSpherePosition(selectedNpc2.transform.position);
- }
- }
- else if (!MonoBehaviourSingleton<CombatManager>.GetInstance(false).inCombat)
- {
- if ((UnityEngine.Object) this.GetFirstSelectedPlayer() == (UnityEngine.Object) null && MonoBehaviourSingleton<Game>.GetInstance(false).party.Count > 0)
- {
- PC pc = MonoBehaviourSingleton<Game>.GetInstance(false).party[0];
- }
- if (this.selectedMobs.Count == 0)
- {
- this.ClearSelection(false);
- using (List<PC>.Enumerator enumerator = MonoBehaviourSingleton<Game>.GetInstance(false).party.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC current = enumerator.Current;
- if ((double) current.curHP > 0.0)
- {
- current.ShowSelectedFX(true);
- this.selectedMobs.Add((Mob) current);
- break;
- }
- }
- }
- }
- else
- {
- List<PC> list = new List<PC>((IEnumerable<PC>) MonoBehaviourSingleton<Game>.GetInstance(false).party);
- if (Input.GetKey(KeyCode.LeftShift))
- list.Reverse();
- using (List<PC>.Enumerator enumerator = list.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC current = enumerator.Current;
- if ((double) current.curHP > 0.0)
- {
- if ((UnityEngine.Object) m == (UnityEngine.Object) null || m is NPC)
- m = (Mob) current;
- if (flag)
- {
- current.MakeLeader();
- this.AddToSelection((Mob) current);
- flag = false;
- break;
- }
- else if (this.selectedMobs.Count > 0 && this.selectedMobs.Contains((Mob) current))
- {
- this.RemoveFromSelection((Mob) current, true);
- flag = true;
- }
- }
- }
- }
- if ((flag || this.selectedMobs.Count == 0) && (UnityEngine.Object) m != (UnityEngine.Object) null)
- {
- if (m is PC)
- (m as PC).MakeLeader();
- this.AddToSelection(m);
- }
- }
- }
- if (this.selectedMobs.Count > 2 || this.selectedMobs.Count <= 0)
- return;
- this.ignoreMousePosition = true;
- this.ignoredMousePosition = Input.mousePosition;
- MonoBehaviourSingleton<Game>.GetInstance(false).cameraController.Snap(this.selectedMobs[this.selectedMobs.Count - 1].transform.position, false);
- }
- private bool IsOnScreen(GameObject g)
- {
- Vector3 vector3 = Camera.main.WorldToViewportPoint(g.transform.position);
- if ((double) vector3.x > 0.0 && (double) vector3.x < 1.0 && ((double) vector3.y > 0.0 && (double) vector3.y < 1.0))
- return (double) vector3.z > 0.0;
- else
- return false;
- }
- private Rect MakeSelectionRect(Vector3 minP, Vector3 maxP)
- {
- return new Rect()
- {
- xMin = Mathf.Min(minP.x, maxP.x),
- yMin = Mathf.Min(minP.y, maxP.y),
- xMax = Mathf.Max(minP.x, maxP.x),
- yMax = Mathf.Max(minP.y, maxP.y)
- };
- }
- private void SetupFormation(ref FormationTemplate formation, FormationTemplate formationTemplate)
- {
- if ((UnityEngine.Object) formation != (UnityEngine.Object) null && (bool) ((UnityEngine.Object) formation.gameObject))
- UnityEngine.Object.Destroy((UnityEngine.Object) formation.gameObject);
- formation = UnityEngine.Object.Instantiate((UnityEngine.Object) formationTemplate) as FormationTemplate;
- foreach (Transform transform in formation.GetComponentsInChildren<Transform>())
- {
- GameObject primitive = GameObject.CreatePrimitive(PrimitiveType.Sphere);
- primitive.transform.parent = transform;
- primitive.renderer.material.color = Color.yellow;
- primitive.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
- primitive.transform.localPosition = Vector3.zero;
- }
- formation.transform.localScale *= 1.2f;
- formation.gameObject.SetActive(false);
- }
- public PC ClosestSelectedPC(Vector3 pos)
- {
- float num = float.PositiveInfinity;
- PC pc = (PC) null;
- using (List<PC>.Enumerator enumerator = this.activePCs.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- PC current = enumerator.Current;
- float sqrMagnitude = (current.transform.position - pos).sqrMagnitude;
- if ((double) sqrMagnitude < (double) num)
- {
- num = sqrMagnitude;
- pc = current;
- }
- }
- }
- return pc;
- }
- public PC SelectedLeaderPC()
- {
- return MonoBehaviourSingleton<Game>.GetInstance(false).pcLeader;
- }
- public void SetFreezeInput(bool freeze, string reason = "<none>")
- {
- this.cameraMove = (Vector4) Vector3.zero;
- this.freezeInput = freeze;
- }
- public bool IsInputFrozen()
- {
- return this.freezeInput;
- }
- public bool IsZoomInputFrozen()
- {
- return this.freezeInput && !Drama.isConversationOn || MonoBehaviourSingleton<GUIManager>.GetInstance(false).IsModalMenuActive() || (!MonoBehaviourSingleton<HUD_Controller>.HasInstance() || !((UnityEngine.Object) UICamera.selectedObject == (UnityEngine.Object) MonoBehaviourSingleton<HUD_Controller>.GetInstance(false).gameObject) || MonoBehaviourSingleton<GUIManager>.GetInstance(false).WillUseMouseClick()) && (!MonoBehaviourSingleton<ConversationHUD>.HasInstance() || !((UnityEngine.Object) UICamera.selectedObject == (UnityEngine.Object) MonoBehaviourSingleton<ConversationHUD>.GetInstance(false).gameObject));
- }
- public PC GetFirstSelectedPlayer()
- {
- return MonoBehaviourSingleton<Game>.GetInstance(false).GetFirstSelectedPC();
- }
- public void SelectEntireParty()
- {
- for (int index = 0; index < MonoBehaviourSingleton<Game>.GetInstance(false).party.Count; ++index)
- this.AddToSelection((Mob) MonoBehaviourSingleton<Game>.GetInstance(false).party[index]);
- }
- public bool IsPartySelected()
- {
- for (int index = 0; index < MonoBehaviourSingleton<Game>.GetInstance(false).party.Count; ++index)
- {
- if (!MonoBehaviourSingleton<Game>.GetInstance(false).party[index].isSelected)
- return false;
- }
- return true;
- }
- private void RevertToPreviousSelection()
- {
- if (this.previousSelections != null)
- {
- this.ClearSelection(false);
- for (int index = 0; index < Mathf.Min(this.previousSelections.Length, MonoBehaviourSingleton<Game>.GetInstance(false).party.Count); ++index)
- {
- if (this.previousSelections[index])
- this.AddToSelection((Mob) MonoBehaviourSingleton<Game>.GetInstance(false).party[index]);
- }
- }
- else
- this.AddToSelection((Mob) MonoBehaviourSingleton<Game>.GetInstance(false).party[0]);
- }
- public void TogglePartySelected()
- {
- if (this.IsPartySelected())
- {
- this.RevertToPreviousSelection();
- }
- else
- {
- this.previousSelections = new bool[MonoBehaviourSingleton<Game>.GetInstance(false).party.Count];
- for (int index = 0; index < this.previousSelections.Length; ++index)
- this.previousSelections[index] = MonoBehaviourSingleton<Game>.GetInstance(false).party[index].isSelected;
- this.SelectEntireParty();
- }
- }
- public CombatAStarNode GetCurrentSquare()
- {
- return this.mouseoverSquare;
- }
- public void SaveSelectedToBackup()
- {
- this.selectedBackup = new List<Mob>((IEnumerable<Mob>) this.selectedMobs);
- }
- public void RestoreSelectedFromBackup()
- {
- this.ClearSelection(false);
- using (List<Mob>.Enumerator enumerator = this.selectedBackup.GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- Mob current = enumerator.Current;
- if ((UnityEngine.Object) current != (UnityEngine.Object) null && (UnityEngine.Object) current.gameObject != (UnityEngine.Object) null && current.mobState != Mob.MobState.DEAD)
- this.AddToSelection(current);
- }
- }
- }
- public void RemoveSelectedFromBackup(Mob mob)
- {
- this.selectedBackup.Remove(mob);
- }
- public void AddToSelectedBackup(Mob mob)
- {
- if (this.selectedBackup.Contains(mob))
- return;
- this.selectedBackup.Add(mob);
- }
- public bool IsKeyBound(string keyCode, ref string boundCommandName)
- {
- for (int index = 0; index < InputManager.buttonEvents.Length; ++index)
- {
- if (cInput.GetText(InputManager.buttonEvents[index]).Equals(keyCode, StringComparison.CurrentCultureIgnoreCase))
- {
- boundCommandName = InputManager.buttonEvents[index];
- return true;
- }
- }
- return false;
- }
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static bool ClipCursor(ref InputManager.RECT rcClip);
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static bool ClipCursor(IntPtr rcClip);
- [DllImport("user32.dll")]
- private static int GetForegroundWindow();
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static bool GetClientRect(int hWnd, ref InputManager.RECT lpRect);
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static bool ClientToScreen(int hWnd, ref InputManager.POINT lpPoint);
- private void ClientRectToScreenRect(int hWnd, ref InputManager.RECT rect)
- {
- InputManager.POINT lpPoint1 = new InputManager.POINT(rect.Left, rect.Bottom);
- InputManager.POINT lpPoint2 = new InputManager.POINT(rect.Right, rect.Top);
- InputManager.ClientToScreen(hWnd, ref lpPoint1);
- InputManager.ClientToScreen(hWnd, ref lpPoint2);
- rect.Left = lpPoint1.x;
- rect.Bottom = lpPoint1.y;
- rect.Right = lpPoint2.x;
- rect.Top = lpPoint2.y;
- }
- private void SetCursorClipRect(bool focus)
- {
- if (focus)
- {
- InputManager.RECT rect = new InputManager.RECT();
- int foregroundWindow = InputManager.GetForegroundWindow();
- InputManager.GetClientRect(foregroundWindow, ref rect);
- this.ClientRectToScreenRect(foregroundWindow, ref rect);
- InputManager.ClipCursor(ref rect);
- }
- else
- InputManager.ClipCursor(IntPtr.Zero);
- }
- public struct RECT
- {
- public int Left;
- public int Top;
- public int Right;
- public int Bottom;
- public RECT(int left, int top, int right, int bottom)
- {
- this.Left = left;
- this.Top = top;
- this.Right = right;
- this.Bottom = bottom;
- }
- }
- public struct POINT
- {
- public int x;
- public int y;
- public POINT(int X, int Y)
- {
- this.x = X;
- this.y = Y;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement