Exemple #1
0
    private void ShowUnitView()
    {
        if (unitSelected == null)
        {
            return;
        }
        UnitGraphics unitGraphics = unitSelected.UnitGraphics;

        unitGraphics.unitMarker.Switch(false);
        GameObject graphics = unitGraphics.gameObject;

        unitViewer = Instantiate(
            graphics,
            graphics.transform.position,
            graphics.transform.rotation
            ).GetComponent <UnitViewer>();
        unitViewer.Show(unitSelected);
    }
            static bool Prefix(RegionViewer __instance, string path, Area area, ItemPutInfo info, ref GameObject __result, bool isFloorLayer)
            {
                if (!enabled || Module <ScenarioModule> .Self.CurrentScenarioName != "Main" || !outsideUnits.ContainsKey(info.cellIndex))
                {
                    return(true);
                }


                GameObject gameObject = (GameObject)typeof(RegionViewer).GetMethod("CreateGameObj", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(string) }, new ParameterModifier[0]).Invoke(__instance, new object[] { path });

                typeof(RegionViewer).GetMethod("FreshLocalPosition", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { gameObject.transform, info, area });
                typeof(RegionViewer).GetMethod("FreshLocalRotation", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { gameObject.transform, info });

                UnitViewer unitViewer = gameObject.GetComponentInChildren <UnitViewer>();

                if (unitViewer == null)
                {
                    unitViewer = gameObject.AddComponent <UnitViewer>();
                }
                if (unitViewer != null)
                {
                    Unit unitByCell = outsideUnits[info.cellIndex].unit;

                    unitViewer.SetUnit(unitByCell);
                    typeof(RegionViewer).GetMethod("SetRegionName", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { unitViewer });

                    if (!unitByCell.immobile && !(unitByCell is FloorCell))
                    {
                        MethodInfo    method = __instance.GetType().GetMethod("TakeUpHomeItem", BindingFlags.NonPublic | BindingFlags.Instance);
                        Action <Unit> action = (Action <Unit>)Delegate.CreateDelegate(typeof(Action <Unit>), __instance, method);
                        unitViewer.InitHomeItemThing(action);
                    }
                    if (!unitByCell.immobile && unitByCell.CustomColorCount > 0)
                    {
                        unitViewer.InitColorChange();
                    }
                }
                gameObject.SetActive(true);
                __result = gameObject;
                return(false);
            }
Exemple #3
0
 static bool Prefix(UnitViewer __instance, MatColorConfig[] ___configs, ref int __result)
 {
     if (!enabled || Module <ScenarioModule> .Self.CurrentScenarioName != "Main")
     {
         return(true);
     }
     try
     {
         if (___configs == null)
         {
             __result = 0;
             return(false);
         }
         __result = Mathf.Min(__instance.unit.CustomColorCount, ___configs.Length);
         return(false);
     }
     catch
     {
         __result = 0;
         return(false);
     }
 }
 public void Detach(UnitViewer investor)
 {
     unitViewers.Remove(investor);
 }
 public void Attach(UnitViewer investor)
 {
     unitViewers.Add(investor);
 }
Exemple #6
0
 private void HideUnitView()
 {
     unitViewer?.Hide();
     unitViewer   = null;
     unitSelected = null;
 }