コード例 #1
0
        protected override void OnSpawn()
        {
            KBatchedAnimController component = this.GetComponent <KBatchedAnimController>();

            if (hasMeter)
            {
                meter = new MeterController((KAnimControllerBase)component, "U2H_meter_target", "meter", Meter.Offset.Behind, Grid.SceneLayer.NoLayer, new Vector3(-0.4f, 0.5f, -0.1f), new string[4]
                {
                    "U2H_meter_target",
                    "U2H_meter_tank",
                    "U2H_meter_waterbody",
                    "U2H_meter_level"
                });
            }
            smi.StartSM();
            UpdateMeter();

            Tutorial.Instance.oxygenGenerators.Add(base.gameObject);
        }
コード例 #2
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        base.OnToggle += CircuitOnToggle;
        int        cell       = Grid.PosToCell(base.transform.GetPosition());
        GameObject gameObject = Grid.Objects[cell, (int)objectLayer];
        Wire       wire       = (!((UnityEngine.Object)gameObject != (UnityEngine.Object)null)) ? null : gameObject.GetComponent <Wire>();

        if ((UnityEngine.Object)wire == (UnityEngine.Object)null)
        {
            wireConnectedGUID = GetComponent <KSelectable>().AddStatusItem(Db.Get().BuildingStatusItems.NoWireConnected, null);
        }
        AttachWire(wire);
        wasOn = switchedOn;
        UpdateCircuit(true);
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        component.Play((!switchedOn) ? "off" : "on", KAnim.PlayMode.Once, 1f, 0f);
    }
コード例 #3
0
    public Sprite GetUIIcon()
    {
        Sprite result = null;

        if ((UnityEngine.Object)Icon != (UnityEngine.Object)null)
        {
            result = Icon;
        }
        else
        {
            GameObject             prefab    = Assets.GetPrefab(Result);
            KBatchedAnimController component = prefab.GetComponent <KBatchedAnimController>();
            if ((UnityEngine.Object)component != (UnityEngine.Object)null)
            {
                result = Def.GetUISpriteFromMultiObjectAnim(component.AnimFiles[0], "ui", false, string.Empty);
            }
        }
        return(result);
    }
コード例 #4
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        Building component = GetComponent <Building>();

        inputCell  = component.GetUtilityInputCell();
        outputCell = component.GetUtilityOutputCell();
        ConduitFlow liquidConduitFlow = Game.Instance.liquidConduitFlow;

        liquidConduitFlow.onConduitsRebuilt += OnConduitsRebuilt;
        liquidConduitFlow.AddConduitUpdater(OnConduitUpdate, ConduitFlowPriority.Default);
        KBatchedAnimController component2 = GetComponent <KBatchedAnimController>();

        fillMeter          = new MeterController(component2, "meter_target", "meter", Meter.Offset.Behind, Grid.SceneLayer.NoLayer, new Vector3(0.4f, 3.2f, 0.1f));
        contaminationMeter = new MeterController(component2, "meter_target", "meter_dirty", Meter.Offset.Behind, Grid.SceneLayer.NoLayer, new Vector3(0.4f, 3.2f, 0.1f));
        Components.Toilets.Add(this);
        base.smi.StartSM();
        base.smi.ShowFillMeter();
    }
コード例 #5
0
    protected override void Start()
    {
        tuning = TuningData <Tuning> .Get();

        SetupCameras();
        base.Start();
        for (int i = 0; i < anims.Length; i++)
        {
            int minionIndex = i;
            KBatchedAnimController kBatchedAnimController = anims[i].minions[0];
            kBatchedAnimController.onAnimComplete += delegate(HashedString name)
            {
                WaitForABit(minionIndex, name);
            };
            WaitForABit(i, HashedString.Invalid);
        }
        dreckoController         = base.transform.GetChild(0).Find("startmenu_drecko").GetComponent <KBatchedAnimController>();
        dreckoController.enabled = false;
        nextDreckoTime           = UnityEngine.Random.Range(tuning.minFirstDreckoInterval, tuning.maxFirstDreckoInterval) + Time.unscaledTime;
    }
コード例 #6
0
    private void SetAllowedDirection(WorkableReactable.AllowedDirection new_direction)
    {
        KBatchedAnimController component     = GetComponent <KBatchedAnimController>();
        DirectionInfo          directionInfo = directionInfos[(int)new_direction];
        bool flag        = directionInfo.allowLeft && directionInfo.allowRight;
        bool is_visible  = !flag && directionInfo.allowLeft;
        bool is_visible2 = !flag && directionInfo.allowRight;

        component.SetSymbolVisiblity("arrow2", flag);
        component.SetSymbolVisiblity("arrow_left", is_visible);
        component.SetSymbolVisiblity("arrow_right", is_visible2);
        if (new_direction != allowedDirection)
        {
            allowedDirection = new_direction;
            if (onDirectionChanged != null)
            {
                onDirectionChanged(allowedDirection);
            }
        }
    }
コード例 #7
0
    public void SpawnCO2(Vector3 position, float mass, float temperature)
    {
        position.z = Grid.GetLayerZ(Grid.SceneLayer.Front);
        GameObject gameObject = co2Pool.GetInstance();

        gameObject.transform.SetPosition(position);
        gameObject.SetActive(true);
        CO2 component = gameObject.GetComponent <CO2>();

        component.mass              = mass;
        component.temperature       = temperature;
        component.velocity          = Vector3.zero;
        component.lifetimeRemaining = 3f;
        KBatchedAnimController component2 = component.GetComponent <KBatchedAnimController>();

        component2.TintColour    = tintColour;
        component2.onDestroySelf = OnDestroyCO2;
        component.StartLoop();
        co2Items.Add(component);
    }
コード例 #8
0
    private void OnStartedTalking(object data)
    {
        ConversationManager.StartedTalkingEvent startedTalkingEvent = (ConversationManager.StartedTalkingEvent)data;
        GameObject talker = startedTalkingEvent.talker;

        if ((Object)talker == (Object)base.worker.gameObject)
        {
            KBatchedAnimController component = base.worker.GetComponent <KBatchedAnimController>();
            string anim = startedTalkingEvent.anim;
            anim += Random.Range(1, 9).ToString();
            component.Play(anim, KAnim.PlayMode.Once, 1f, 0f);
            component.Queue("idle", KAnim.PlayMode.Loop, 1f, 0f);
        }
        else
        {
            Facing component2 = base.worker.GetComponent <Facing>();
            component2.Face(talker.transform.GetPosition());
            lastTalker = talker;
        }
    }
コード例 #9
0
        private void RefreshDepthAvailable()
        {
            bool waterFound;
            int  depthAvailable = GetDepthAvailable(parent, out waterFound);

            if (depthAvailable != previousDepthAvailable || waterFound != previousWaterFound)
            {
                KBatchedAnimController kBatchedAnimController = GetComponent <KBatchedAnimController>();
                if (depthAvailable == 0)
                {
                    kBatchedAnimController.enabled = false;
                }
                else
                {
                    kBatchedAnimController.enabled = true;
                    kBatchedAnimController.Offset  = new Vector3(0, -depthAvailable + 0.35f);
                    for (int i = 1; i <= MaxDepth; i++)
                    {
                        kBatchedAnimController.SetSymbolVisiblity("line" + i.ToString(), i <= depthAvailable);
                        kBatchedAnimController.SetSymbolVisiblity("lineplace" + i.ToString(), i <= depthAvailable);
                    }
                    kBatchedAnimController.sceneLayer = Grid.SceneLayer.BuildingBack;
                    kBatchedAnimController.Play(kBatchedAnimController.initialAnim, KAnim.PlayMode.Loop, 1f, 0f);
                }
                if (occupyTiles)
                {
                    OccupyArea(parent, depthAvailable);
                }
                if (!isPreview)
                {
                    KSelectable kSelectable = parent.GetComponent <KSelectable>();
                    if (kSelectable != null)
                    {
                        kSelectable.ToggleStatusItem(statusItemNoDepth, depthAvailable == 0);
                        kSelectable.ToggleStatusItem(statusItemNoWater, depthAvailable > 0 && !waterFound);
                    }
                }
                previousDepthAvailable = depthAvailable;
                previousWaterFound     = waterFound;
            }
        }
コード例 #10
0
    public static GameObject ConfigBasicEntity(GameObject template, string id, string name, string desc, float mass, bool unitMass, KAnimFile anim, string initialAnim, Grid.SceneLayer sceneLayer, SimHashes element = SimHashes.Creature, List <Tag> additionalTags = null, float defaultTemperature = 293f)
    {
        ConfigEntity(template, id, name, true);
        KPrefabID kPrefabID = template.AddOrGet <KPrefabID>();

        if (additionalTags != null)
        {
            foreach (Tag additionalTag in additionalTags)
            {
                kPrefabID.AddTag(additionalTag, false);
            }
        }
        KBatchedAnimController kBatchedAnimController = template.AddOrGet <KBatchedAnimController>();

        kBatchedAnimController.AnimFiles = new KAnimFile[1]
        {
            anim
        };
        kBatchedAnimController.sceneLayer  = sceneLayer;
        kBatchedAnimController.initialAnim = initialAnim;
        template.AddOrGet <StateMachineController>();
        PrimaryElement primaryElement = template.AddOrGet <PrimaryElement>();

        primaryElement.ElementID   = element;
        primaryElement.Temperature = defaultTemperature;
        if (unitMass)
        {
            primaryElement.MassPerUnit = mass;
            primaryElement.Units       = 1f;
            GameTags.DisplayAsUnits.Add(kPrefabID.PrefabTag);
        }
        else
        {
            primaryElement.Mass = mass;
        }
        InfoDescription infoDescription = template.AddOrGet <InfoDescription>();

        infoDescription.description = desc;
        template.AddOrGet <Notifier>();
        return(template);
    }
コード例 #11
0
ファイル: LaserTurret.cs プロジェクト: phcorcoran/ONI-Mods
        protected override void OnSpawn()
        {
            base.OnSpawn();
            // self position
            _xy0 = Grid.PosToXY(transform.position);

            // range detector
            var anchorMinRotatedOffset = _rotatable.GetRotatedCellOffset(new CellOffset(visualizerX, visualizerY));
            var anchorMinRotated       = Grid.CellToPos2D(Grid.OffsetCell(Grid.PosToCell(_xy0), anchorMinRotatedOffset));
            var sizeRotatedOffset      = _rotatable.GetRotatedCellOffset(new CellOffset(visualizerWidth - 1, visualizerHeight - 1));

            _rangeRect = new Rect(anchorMinRotated, sizeRotatedOffset.ToVector3());

            // anim
            _hitEffectPrefab = Assets.GetPrefab((Tag)EffectConfigs.AttackSplashId);
            var component = GetComponent <KBatchedAnimController>();
            var armName   = component.name + ".gun";

            _armGo = new GameObject(armName);
            _armGo.SetActive(false);
            _armGo.transform.parent = component.transform;
            _loopingSounds          = _armGo.AddComponent <LoopingSounds>();
            _rotateSound            = GlobalAssets.GetSound(_rotateSound);
            _armGo.AddComponent <KPrefabID>().PrefabTag = new Tag(armName);
            _armAnimCtrl             = _armGo.AddComponent <KBatchedAnimController>();
            _armAnimCtrl.AnimFiles   = new[] { component.AnimFiles[0] };
            _armAnimCtrl.initialAnim = "gun";
            _armAnimCtrl.isMovable   = true;
            _armAnimCtrl.sceneLayer  = Grid.SceneLayer.TransferArm;
            component.SetSymbolVisiblity((KAnimHashedString)"gun_target", false);
            Vector3 column = component.GetSymbolTransform(new HashedString("gun_target"), out _).GetColumn(3);

            column.z = Grid.GetLayerZ(Grid.SceneLayer.TransferArm);
            _armGo.transform.SetPosition(column);
            _armGo.SetActive(true);
            _link = new KAnimLink(component, _armAnimCtrl);
            RotateArm(0f, 0f);
            ClearTarget();
            smi.StartSM();
            Subscribe((int)GameHashes.CopySettings, OnCopySettings);
        }
    private static void AddGuide(GameObject go, bool occupy_tiles)
    {
        GameObject gameObject = new GameObject();

        gameObject.transform.parent = go.transform;
        gameObject.transform.SetLocalPosition(Vector3.zero);
        KBatchedAnimController kBatchedAnimController = gameObject.AddComponent <KBatchedAnimController>();

        kBatchedAnimController.Offset    = go.GetComponent <Building>().Def.GetVisualizerOffset();
        kBatchedAnimController.AnimFiles = new KAnimFile[1]
        {
            Assets.GetAnim(new HashedString("waterpump_kanim"))
        };
        kBatchedAnimController.initialAnim    = "place_guide";
        kBatchedAnimController.visibilityType = KAnimControllerBase.VisibilityType.OffscreenUpdate;
        kBatchedAnimController.isMovable      = true;
        PumpingStationGuide pumpingStationGuide = gameObject.AddComponent <PumpingStationGuide>();

        pumpingStationGuide.parent      = go;
        pumpingStationGuide.occupyTiles = occupy_tiles;
    }
コード例 #13
0
    public static void SetSpawnNavType(GameObject inst)
    {
        int       cell      = Grid.PosToCell(inst);
        Navigator component = inst.GetComponent <Navigator>();

        if ((Object)component != (Object)null)
        {
            if (Grid.IsSolidCell(cell))
            {
                component.SetCurrentNavType(NavType.Solid);
                inst.transform.SetPosition(Grid.CellToPosCBC(cell, Grid.SceneLayer.FXFront));
                KBatchedAnimController component2 = inst.GetComponent <KBatchedAnimController>();
                component2.SetSceneLayer(Grid.SceneLayer.FXFront);
            }
            else
            {
                KBatchedAnimController component3 = inst.GetComponent <KBatchedAnimController>();
                component3.SetSceneLayer(Grid.SceneLayer.Creatures);
            }
        }
    }
コード例 #14
0
 protected void RefreshAnimation()
 {
     if (!cleaningUp)
     {
         KBatchedAnimController component = GetComponent <KBatchedAnimController>();
         int outputCell = base.OutputCell;
         LogicCircuitNetwork logicCircuitNetwork = Game.Instance.logicCircuitSystem.GetNetworkForCell(outputCell) as LogicCircuitNetwork;
         if (logicCircuitNetwork == null)
         {
             component.Play("off", KAnim.PlayMode.Once, 1f, 0f);
         }
         else if (base.RequiresTwoInputs)
         {
             component.Play("on_" + (inputOne.Value + inputTwo.Value * 2 + outputValue * 4).ToString(), KAnim.PlayMode.Once, 1f, 0f);
         }
         else
         {
             component.Play("on_" + (inputOne.Value + outputValue * 4).ToString(), KAnim.PlayMode.Once, 1f, 0f);
         }
     }
 }
コード例 #15
0
        public PTextArea DescriptionArea()
        {
            return(new PTextArea("description field")
            {
                FlexSize = Vector2.one,
                Text = (currentTarget != null) ? currentTarget.activateText : "",

                OnTextChanged = (go, text) =>
                {
                    currentTarget.activateText = text;
                    if (currentTarget == null)
                    {
                        return;
                    }
                    // change the anim looking on the text
                    KBatchedAnimController animController = currentTarget.gameObject.AddOrGet <KBatchedAnimController>();
                    animController.Play(currentTarget.activateText.IsNullOrWhiteSpace() ? "empty" : "full", KAnim.PlayMode.Paused);
                },
                LineCount = 6,
            });
        }
    public override void DoPostConfigureComplete(GameObject go)
    {
        GeneratedBuildings.RegisterLogicPorts(go, LogicOperationalController.INPUT_PORTS_0_0);
        go.AddOrGet <LogicOperationalController>();
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
        go.AddOrGet <BuildingComplete>().isManuallyOperated = true;
        go.AddOrGet <LoopingSounds>();
        Prioritizable.AddRef(go);
        Generator generator = go.AddOrGet <Generator>();

        generator.powerDistributionOrder = 10;
        ManualGenerator manualGenerator = go.AddOrGet <ManualGenerator>();

        manualGenerator.SetSliderValue(50f, 0);
        manualGenerator.workLayer = Grid.SceneLayer.BuildingFront;
        KBatchedAnimController kBatchedAnimController = go.AddOrGet <KBatchedAnimController>();

        kBatchedAnimController.fgLayer     = Grid.SceneLayer.BuildingFront;
        kBatchedAnimController.initialAnim = "off";
        Tinkerable.MakePowerTinkerable(go);
    }
コード例 #17
0
        public void Activate()
        {
            //this.link = new KAnimLink(building_controller, meter_controller);
            effect = FXHelpers.CreateEffect("fab_fx_kanim", kBatchedAnimController.transform.GetPosition(), kBatchedAnimController.transform);
            effect.destroyOnAnimComplete = false;
            effect.randomiseLoopedOffset = true;
            effect.FlipX = kBatchedAnimController.FlipX;

            var pos = new Vector3(effect.FlipX ? -0.5f : 0.5f, 0, -1f);

            effect.transform.SetLocalPosition(pos);
            ForceToFront();
            effect.Play("effect", KAnim.PlayMode.Paused, 1f);


            StartCoroutine(ShiftColors());

            sparkleFx = Util.KInstantiate(EffectPrefabs.Instance.SparkleStreakFX, kBatchedAnimController.transform.GetPosition() + new Vector3(1f, 0.5f, 0.4f));
            sparkleFx.transform.SetParent(kBatchedAnimController.transform);
            sparkleFx.SetActive(true);
        }
コード例 #18
0
    public static GameObject CreateFabricationVisualizer(GameObject result)
    {
        KBatchedAnimController component  = result.GetComponent <KBatchedAnimController>();
        GameObject             gameObject = new GameObject();

        gameObject.name = result.name + "Visualizer";
        gameObject.SetActive(false);
        gameObject.transform.SetLocalPosition(Vector3.zero);
        KBatchedAnimController kBatchedAnimController = gameObject.AddComponent <KBatchedAnimController>();

        kBatchedAnimController.AnimFiles   = component.AnimFiles;
        kBatchedAnimController.initialAnim = "fabricating";
        kBatchedAnimController.isMovable   = true;
        KBatchedAnimTracker kBatchedAnimTracker = gameObject.AddComponent <KBatchedAnimTracker>();

        kBatchedAnimTracker.symbol             = new HashedString("meter_ration");
        kBatchedAnimTracker.offset             = Vector3.zero;
        kBatchedAnimTracker.skipInitialDisable = true;
        Object.DontDestroyOnLoad(gameObject);
        return(gameObject);
    }
コード例 #19
0
    public static void RemoveHat(KBatchedAnimController controller)
    {
        AccessorySlot hat       = Db.Get().AccessorySlots.Hat;
        Accessorizer  component = controller.GetComponent <Accessorizer>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            Accessory accessory = component.GetAccessory(hat);
            if (accessory != null)
            {
                component.RemoveAccessory(accessory);
            }
        }
        else
        {
            controller.GetComponent <SymbolOverrideController>().TryRemoveSymbolOverride(hat.targetSymbolId, 4);
        }
        controller.SetSymbolVisiblity(hat.targetSymbolId, false);
        controller.SetSymbolVisiblity(Db.Get().AccessorySlots.HatHair.targetSymbolId, false);
        controller.SetSymbolVisiblity(Db.Get().AccessorySlots.Hair.targetSymbolId, true);
    }
        public static void DropAllCreatures(SMInstance smi)
        {
            Storage component = smi.master.GetComponent <Storage>();

            if (!component.IsEmpty())
            {
                List <GameObject> items = component.items;
                int     count           = items.Count;
                int     cell            = Grid.OffsetCell(Grid.PosToCell(smi.transform.GetPosition()), smi.master.spawnOffset);
                Vector3 position        = Grid.CellToPosCBC(cell, Grid.SceneLayer.Creatures);
                for (int num = count - 1; num >= 0; num--)
                {
                    GameObject gameObject = items[num];
                    component.Drop(gameObject, true);
                    gameObject.transform.SetPosition(position);
                    KBatchedAnimController component2 = gameObject.GetComponent <KBatchedAnimController>();
                    component2.SetSceneLayer(Grid.SceneLayer.Creatures);
                }
                smi.master.RefreshCreatureCount(null);
            }
        }
コード例 #21
0
    private void HideHelmet()
    {
        is_shown = false;
        KBatchedAnimController assigneeController = GetAssigneeController();

        if (!((Object)assigneeController == (Object)null))
        {
            KAnimHashedString kAnimHashedString = "snapTo_neck";
            if (!string.IsNullOrEmpty(anim_file))
            {
                SymbolOverrideController component = assigneeController.GetComponent <SymbolOverrideController>();
                if ((Object)component == (Object)null)
                {
                    return;
                }
                component.RemoveSymbolOverride(kAnimHashedString, 6);
            }
            assigneeController.SetSymbolVisiblity(kAnimHashedString, false);
            UpdateJets();
        }
    }
コード例 #22
0
 private void DisplayDuplicants(RetiredColonyData data, GameObject container, int range_min = -1, int range_max = -1)
 {
     for (int num = container.transform.childCount - 1; num >= 0; num--)
     {
         UnityEngine.Object.DestroyImmediate(container.transform.GetChild(num).gameObject);
     }
     for (int i = 0; i < data.Duplicants.Length; i++)
     {
         if (i < range_min || (i > range_max && range_max != -1))
         {
             GameObject gameObject = new GameObject();
             gameObject.transform.SetParent(container.transform);
         }
         else
         {
             RetiredColonyData.RetiredDuplicantData retiredDuplicantData = data.Duplicants[i];
             GameObject          gameObject2 = Util.KInstantiateUI(duplicantPrefab, container, true);
             HierarchyReferences component   = gameObject2.GetComponent <HierarchyReferences>();
             component.GetReference <LocText>("NameLabel").SetText(retiredDuplicantData.name);
             component.GetReference <LocText>("AgeLabel").SetText(string.Format(UI.RETIRED_COLONY_INFO_SCREEN.DUPLICANT_AGE, retiredDuplicantData.age.ToString()));
             component.GetReference <LocText>("SkillLabel").SetText(string.Format(UI.RETIRED_COLONY_INFO_SCREEN.SKILL_LEVEL, retiredDuplicantData.skillPointsGained.ToString()));
             SymbolOverrideController reference = component.GetReference <SymbolOverrideController>("SymbolOverrideController");
             reference.RemoveAllSymbolOverrides(0);
             KBatchedAnimController componentInChildren = gameObject2.GetComponentInChildren <KBatchedAnimController>();
             componentInChildren.SetSymbolVisiblity("snapTo_neck", false);
             componentInChildren.SetSymbolVisiblity("snapTo_goggles", false);
             componentInChildren.SetSymbolVisiblity("snapTo_hat", false);
             componentInChildren.SetSymbolVisiblity("snapTo_hat_hair", false);
             foreach (KeyValuePair <string, string> accessory in retiredDuplicantData.accessories)
             {
                 KAnim.Build.Symbol symbol        = Db.Get().Accessories.Get(accessory.Value).symbol;
                 AccessorySlot      accessorySlot = Db.Get().AccessorySlots.Get(accessory.Key);
                 reference.AddSymbolOverride(accessorySlot.targetSymbolId, symbol, 0);
                 gameObject2.GetComponentInChildren <KBatchedAnimController>().SetSymbolVisiblity(accessory.Key, true);
             }
             reference.ApplyOverrides();
         }
     }
     StartCoroutine(ActivatePortraitsWhenReady(container));
 }
コード例 #23
0
        private void FillFeeder(float mass)
        {
            KBatchedAnimController   component  = smi.GetComponent <KBatchedAnimController>();
            SymbolOverrideController component2 = smi.GetComponent <SymbolOverrideController>();

            KAnim.Build.Symbol symbol     = null;
            Storage            component3 = smi.GetComponent <Storage>();

            if (component3.items.Count > 0 && (Object)component3.items[0] != (Object)null)
            {
                symbol = smi.GetComponent <Storage>().items[0].GetComponent <KBatchedAnimController>().AnimFiles[0].GetData().build.GetSymbol("algae");
            }
            for (int i = 0; i < ballSymbols.Length; i++)
            {
                bool is_visible = mass > (float)(i + 1) * massPerBall;
                component.SetSymbolVisiblity(ballSymbols[i], is_visible);
                if (symbol != null)
                {
                    component2.AddSymbolOverride(ballSymbols[i], symbol, 0);
                }
            }
        }
コード例 #24
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        refreshCallback          = Refresh;
        refreshPartionerCallback = delegate
        {
            Refresh();
        };
        onCollectDecorProvidersCallback = OnCollectDecorProviders;
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        isMovable = ((UnityEngine.Object)component != (UnityEngine.Object)null && component.isMovable);
        Singleton <CellChangeMonitor> .Instance.RegisterCellChangedHandler(base.transform, OnCellChange, "DecorProvider.OnSpawn");

        AttributeInstance attributeInstance = decor;

        attributeInstance.OnDirty = (System.Action)Delegate.Combine(attributeInstance.OnDirty, refreshCallback);
        AttributeInstance attributeInstance2 = decorRadius;

        attributeInstance2.OnDirty = (System.Action)Delegate.Combine(attributeInstance2.OnDirty, refreshCallback);
        Refresh();
    }
 public void Refresh()
 {
     if (connectionManager != null && !skipRefresh)
     {
         int cell = Grid.PosToCell(base.transform.GetPosition());
         Connections = connectionManager.GetConnections(cell, isPhysicalBuilding);
         KBatchedAnimController component = GetComponent <KBatchedAnimController>();
         if ((UnityEngine.Object)component != (UnityEngine.Object)null)
         {
             string text = connectionManager.GetVisualizerString(cell);
             BuildingUnderConstruction component2 = GetComponent <BuildingUnderConstruction>();
             if ((UnityEngine.Object)component2 != (UnityEngine.Object)null && component.HasAnimation(text + "_place"))
             {
                 text += "_place";
             }
             if (text != null && text != string.Empty)
             {
                 component.Play(text, KAnim.PlayMode.Once, 1f, 0f);
             }
         }
     }
 }
コード例 #26
0
        protected override void OnSpawn()
        {
            KBatchedAnimController component = this.GetComponent <KBatchedAnimController>();

            component.TintColour = new Color(0.5f, 0.5f, 1.0f, 1.0f);
            string name = component.name + ".gun";

            this.arm_go = new GameObject(name);
            this.arm_go.SetActive(value: false);
            this.arm_go.transform.parent = component.transform;
            this.looping_sounds          = this.arm_go.AddComponent <LoopingSounds>();
            this.rotateSound             = GlobalAssets.GetSound(this.rotateSound);
            KPrefabID kPrefabID = this.arm_go.AddComponent <KPrefabID>();

            kPrefabID.PrefabTag          = new Tag(name);
            this.arm_anim_ctrl           = this.arm_go.AddComponent <KBatchedAnimController>();
            this.arm_anim_ctrl.AnimFiles = new KAnimFile[1] {
                component.AnimFiles[0]
            };
            this.arm_anim_ctrl.initialAnim = "gun";
            this.arm_anim_ctrl.isMovable   = true;
            this.arm_anim_ctrl.sceneLayer  = Grid.SceneLayer.TransferArm;
            this.arm_anim_ctrl.TintColour  = new Color(0.5f, 0.5f, 1.0f, 1.0f);
            component.SetSymbolVisiblity("gun_target", is_visible: false);
            bool    symbolVisible;
            Vector4 column   = component.GetSymbolTransform(new HashedString("gun_target"), out symbolVisible).GetColumn(3);
            Vector3 position = column;

            position.z = Grid.GetLayerZ(Grid.SceneLayer.TransferArm);
            this.arm_go.transform.SetPosition(position);
            this.arm_go.SetActive(value: true);
            this.link = new KAnimLink(component, this.arm_anim_ctrl);
            this.SetupBeam();
            this.RotateArm(this.rotatable.GetRotatedOffset(Quaternion.Euler(0f, 0f, -this.arm_rot) * Vector3.up), warp: true, 0f);
            this.energyConsumer.UpdatePoweredStatus();
            this.operational.SetActive(true);
            this.selectable.AddStatusItem(charge_status, this);
            this.selectable.AddStatusItem(kills_status, this);
        }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        meter_coolant = new MeterController((KAnimControllerBase)component, "meter_target", "meter_coolant", Meter.Offset.Infront, Grid.SceneLayer.NoLayer, Vector3.zero, (string[])null);
        meter_metal   = new MeterController((KAnimControllerBase)component, "meter_target_metal", "meter_metal", Meter.Offset.Infront, Grid.SceneLayer.NoLayer, Vector3.zero, (string[])null);
        meter_metal.SetPositionPercent(1f);
        smi = new StatesInstance(this);
        smi.StartSM();
        ConduitFlow liquidConduitFlow = Game.Instance.liquidConduitFlow;

        liquidConduitFlow.AddConduitUpdater(OnConduitUpdate, ConduitFlowPriority.Default);
        Building component2 = GetComponent <Building>();

        outputCell = component2.GetUtilityOutputCell();
        workable.OnWorkTickActions = delegate
        {
            float percentComplete = workable.GetPercentComplete();
            meter_metal.SetPositionPercent(percentComplete);
        };
    }
コード例 #28
0
ファイル: KAnimPatches.cs プロジェクト: peterhaneve/ONIMods
        /// <summary>
        /// Applied before SetBatchGroup runs.
        /// </summary>
        internal static bool Prefix(KBatchedAnimController __instance, KAnimFileData kafd)
        {
            var id = __instance.batchGroupID;

            if (id.IsValid)
            {
                PUtil.LogWarning("Batch group should only be set once!");
            }
            else if (kafd == null)
            {
                PUtil.LogWarning("No anim data for {0}!".F(__instance.name));
            }
            else if (id != kafd.batchTag)
            {
                var bild = kafd.build;
                var inst = KAnimBatchManager.Instance();
                if (bild == null)
                {
                    PUtil.LogWarning("No build for anim {0} on {1}!".F(kafd.name, __instance.
                                                                       name));
                }
                else if (!(id = bild.batchTag).IsValid || id == KAnimBatchManager.NO_BATCH)
                {
                    PUtil.LogWarning("Batch is not ready: " + __instance.name);
                }
                else if (inst != null)
                {
                    var bgd = KAnimBatchManager.instance.GetBatchGroupData(id);
                    id = bild.batchTag;
                    __instance.curBuild              = bild;
                    __instance.batchGroupID          = id;
                    __instance.symbolInstanceGpuData = new SymbolInstanceGpuData(bgd.
                                                                                 maxSymbolsPerBuild);
                    __instance.symbolOverrideInfoGpuData = new SymbolOverrideInfoGpuData(bgd.
                                                                                         symbolFrameInstances.Count);
                }
            }
            return(false);
        }
コード例 #29
0
 private void UpdateCircuit(bool should_update_anim = true)
 {
     if ((UnityEngine.Object)attachedWire != (UnityEngine.Object)null)
     {
         if (switchedOn)
         {
             attachedWire.Connect();
         }
         else
         {
             attachedWire.Disconnect();
         }
     }
     if (should_update_anim && wasOn != switchedOn)
     {
         KBatchedAnimController component = GetComponent <KBatchedAnimController>();
         component.Play((!switchedOn) ? "on_pst" : "on_pre", KAnim.PlayMode.Once, 1f, 0f);
         component.Queue((!switchedOn) ? "off" : "on", KAnim.PlayMode.Once, 1f, 0f);
         Game.Instance.userMenu.Refresh(base.gameObject);
     }
     wasOn = switchedOn;
 }
コード例 #30
0
        private static void Postfix(Building __instance)
        {
            List <string> bridges = new List <string>()
            {
                "ExtendedLiquidConduitBridge",
                "ExtendedGasConduitBridge",
                "ExtendedSolidConduitBridge",
                "ExtendedWireBridge",
                "ExtendedWireRefinedBridge",
                "ExtendedLogicWireBridge",
                "ExtendedLogicRibbonBridge",
            };

            // Check to see if the building is on the above list
            string result = bridges.FirstOrDefault(s => __instance.name.Contains(s));

            if (!string.IsNullOrEmpty(result))
            {
                // Stretch the anim
                Debug.Log("Extending " + __instance.name);
                KBatchedAnimController animController = __instance.gameObject.GetComponent <KBatchedAnimController>();
                animController.animWidth = 1.4f;

                // Change the prefab tag on the extended automation bridge
                if (string.Equals(__instance.name, "ExtendedLogicWireBridgeComplete"))
                {
                    KPrefabID kPrefabID = __instance.gameObject.AddOrGet <KPrefabID>();
                    kPrefabID.PrefabTag = TagManager.Create("LogicWireBridge");
                }

                // Change the prefab tag on the extended automation ribbon bridge
                if (string.Equals(__instance.name, "ExtendedLogicRibbonBridgeComplete"))
                {
                    KPrefabID kPrefabID = __instance.gameObject.AddOrGet <KPrefabID>();
                    kPrefabID.PrefabTag = TagManager.Create("LogicRibbonBridge");
                }
            }
        }