Exemple #1
0
 [HarmonyPriority(-10000)] // Extremely low priority. We want this to happen last, since this will only overwrite RotatablePump results
 public static void Postfix(Pump __instance, ref bool __result, Element.State expected_state)
 {
     if (__instance is RotatablePump)
     {
         Rotatable rotatable = __instance.GetComponent <Rotatable>();
         RotatableElementConsumer consumer = __instance.GetComponent <RotatableElementConsumer>();
         //Debug.Log("IsPumpable call " + consumer.rotatableCellOffset + ", " + consumer.sampleCellOffset);
         // Basically a copy of vanilla Pump IsPumpable, but with different initial
         int num = Grid.PosToCell(__instance.transform.GetPosition() + Rotatable.GetRotatedOffset(consumer.rotatableCellOffset, rotatable.GetOrientation()));
         for (int i = 0; i < consumer.consumptionRadius; i++)
         {
             for (int j = 0; j < consumer.consumptionRadius; j++)
             {
                 int  num2 = num + j + Grid.WidthInCells * i;
                 bool flag = Grid.Element[num2].IsState(expected_state);
                 if (flag)
                 {
                     __result = true;
                     return;
                 }
             }
         }
         __result = false;
         return;
     }
 }
Exemple #2
0
 [HarmonyPriority(-10000)] // Extremely low priority. We want this to happen last, since this will only overwrite FanRotatablePassiveElementConsumer variable
 public static void Prefix(ElementConsumer __instance)
 {
     if (__instance is FanRotatablePassiveElementConsumer)
     {
         Vector3   rotatableCellOffset = ((FanRotatablePassiveElementConsumer)__instance).rotatableCellOffset;
         Rotatable rotatable           = __instance.GetComponent <Rotatable>();
         if (rotatable != null)
         {
             __instance.sampleCellOffset = Rotatable.GetRotatedOffset(rotatableCellOffset, rotatable.GetOrientation());
         }
     }
 }
Exemple #3
0
 [HarmonyPriority(-10000)] // Extremely low priority. We want this to happen last, since this will only overwrite RotatableElementConsumer variable
 public static void Prefix(ElementConsumer __instance)
 {
     if (__instance is RotatableElementConsumer)
     {
         Vector3   rotatableCellOffset = ((RotatableElementConsumer)__instance).rotatableCellOffset;
         Rotatable rotatable           = __instance.GetComponent <Rotatable>();
         if (rotatable != null)
         {
             __instance.sampleCellOffset = Rotatable.GetRotatedOffset(rotatableCellOffset, rotatable.GetOrientation());
         }
         //Debug.Log("GetSampleCell call " + rotatableCellOffset + ", " + __instance.sampleCellOffset);
     }
 }
        protected override void OnSpawn()
        {
            KBatchedAnimController component = GetComponent <KBatchedAnimController>();

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

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

            kPrefabID.PrefabTag     = new Tag(name);
            arm_anim_ctrl           = arm_go.AddComponent <KBatchedAnimController>();
            arm_anim_ctrl.AnimFiles = new KAnimFile[1] {
                component.AnimFiles[0]
            };
            arm_anim_ctrl.initialAnim = "gun";
            arm_anim_ctrl.isMovable   = true;
            arm_anim_ctrl.sceneLayer  = Grid.SceneLayer.TransferArm;
            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);
            arm_go.transform.SetPosition(position);
            arm_go.SetActive(value: true);
            link = new KAnimLink(component, arm_anim_ctrl);
            SetupBeam();
            RotateArm(rotatable.GetRotatedOffset(Quaternion.Euler(0f, 0f, -arm_rot) * Vector3.up), warp: true, 0f);
            energyConsumer.UpdatePoweredStatus();
            operational.SetActive(true);
            selectable.AddStatusItem(charge_status, this);
            selectable.AddStatusItem(kills_status, this);
        }
 private void TryEmit(PrimaryElement primary_elem)
 {
     if (primary_elem.Mass >= emitMass)
     {
         plasticMeter.SetPositionPercent(0f);
         GameObject gameObject = storage.Drop(primary_elem.gameObject, true);
         Rotatable  component  = GetComponent <Rotatable>();
         Vector3    vector     = component.transform.GetPosition() + component.GetRotatedOffset(emitOffset);
         int        i          = Grid.PosToCell(vector);
         if (Grid.Solid[i])
         {
             vector += component.GetRotatedOffset(Vector3.left);
         }
         gameObject.transform.SetPosition(vector);
         PrimaryElement primaryElement = storage.FindPrimaryElement(exhaustElement);
         if ((Object)primaryElement != (Object)null)
         {
             int gameCell = Grid.PosToCell(vector);
             SimMessages.AddRemoveSubstance(gameCell, primaryElement.ElementID, null, primaryElement.Mass, primaryElement.Temperature, primaryElement.DiseaseIdx, primaryElement.DiseaseCount, true, -1);
             primaryElement.Mass = 0f;
             primaryElement.ModifyDiseaseCount(-2147483648, "Polymerizer.Exhaust");
         }
     }
 }
Exemple #6
0
        protected override void OnSpawn()
        {
            base.OnSpawn();

            Vector3   position            = transform.GetPosition();
            Rotatable rotatable           = GetComponent <Rotatable>();
            Vector3   rotatedInputOffset  = Rotatable.GetRotatedOffset(new Vector3(0, -1), rotatable.GetOrientation());
            Vector3   rotatedOutputOffset = Rotatable.GetRotatedOffset(new Vector3(0, 1), rotatable.GetOrientation());

            inputCell  = Grid.PosToCell(position + rotatedInputOffset);
            outputCell = Grid.PosToCell(position + rotatedOutputOffset);

            elapsedTime = 0.0f;
            pumpable    = UpdatePumpOperational();
            ventable    = UpdateVentOperational();
        }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        hitEffectPrefab = Assets.GetPrefab("fx_dig_splash");
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();
        string name = component.name + ".gun";

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

        kPrefabID.PrefabTag     = new Tag(name);
        arm_anim_ctrl           = arm_go.AddComponent <KBatchedAnimController>();
        arm_anim_ctrl.AnimFiles = new KAnimFile[1]
        {
            component.AnimFiles[0]
        };
        arm_anim_ctrl.initialAnim = "gun";
        arm_anim_ctrl.isMovable   = true;
        arm_anim_ctrl.sceneLayer  = Grid.SceneLayer.TransferArm;
        component.SetSymbolVisiblity("gun_target", 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);
        arm_go.transform.SetPosition(position);
        arm_go.SetActive(true);
        link = new KAnimLink(component, arm_anim_ctrl);
        Subscribe(-592767678, OnOperationalChangedDelegate);
        RotateArm(rotatable.GetRotatedOffset(Quaternion.Euler(0f, 0f, -45f) * Vector3.up), true, 0f);
        StopDig();
        base.smi.StartSM();
    }
Exemple #8
0
 protected virtual void PositionOccupyingObject()
 {
     if ((Object)rotatable != (Object)null)
     {
         occupyingObject.transform.SetPosition(base.gameObject.transform.GetPosition() + rotatable.GetRotatedOffset(occupyingObjectRelativePosition));
     }
     else
     {
         occupyingObject.transform.SetPosition(base.gameObject.transform.GetPosition() + occupyingObjectRelativePosition);
     }
 }