public override void OnSave(XDataHolder data)
 {
     SpawnChild();
     SaveMapperValues(data);
     if (blockToSpawn != null)
     {
         blockToSpawn.OnSave(data);
     }
 }
コード例 #2
0
        public void AfterEdit(MapperType mapper)
        {
            // We cannot use undo system for PIOs, because they are dymanic
            // trying to save them will result in exception on 'undo' while
            // getting mapper type inside OnEditField
            if (mapper is MCustom <string> )
            {
                BlockMapper.OnEditField(BlockBehaviour, mapper);
            }
            else
            {
                Player localPlayer = Player.GetLocalPlayer();
                if (localPlayer == null || localPlayer.IsHost)
                {
                    return;
                }

                var tempdata = new XDataHolder();
                BlockBehaviour.OnSave(tempdata);
                tempdata.Encode(out byte[] dataBytes);

                var message = ModContext.CpuInfoMessage.CreateMessage(
                    this.BlockBehaviour,
                    dataBytes
                    );
                ModNetworking.SendToHost(message);
            }
        }
コード例 #3
0
        public override void Trigger(AutomatronBlock automatron)
        {
            try
            {
                valueID = int.Parse(blockID);
            } catch { valueID = 0; }
            for (int i = 0; i < 9; i++)
            {
                try
                {
                    fValues[i / 3][i % 3] = float.Parse(sValues[i]);
                } catch { fValues[i / 3][i % 3] = 0; }
            }

            if (valueID == 0)
            {
                fValues[(int)value.pos][(int)dim.z] += 0.5f;
            }

            GameObject Nlock;

            if (blockToSpawn == null)
            {
                SpawnChild();
            }

            Nlock = (GameObject)GameObject.Instantiate(blockToSpawn.gameObject);

            var st = Nlock.transform;
            var at = automatron.transform;

            st.parent        = at;
            st.localPosition = fValues[(int)value.pos];
            st.localRotation = Quaternion.Euler(fValues[(int)value.rot]);
            st.localScale    = fValues[(int)value.scale];
            Nlock.SetActive(true);
            XDataHolder xDataHolder = new XDataHolder {
                WasSimulationStarted = true
            };

            blockToSpawn.OnSave(xDataHolder);
            Nlock.GetComponent <BlockBehaviour>().OnLoad(xDataHolder);
            Nlock.GetComponent <Rigidbody>().isKinematic = false;
            Nlock.transform.SetParent(Machine.Active().SimulationMachine);
        }