Ejemplo n.º 1
0
        public static ThingPayload FromThing(Thing thing)
        {
            var payload = new ThingPayload();

            ThingPayload.CopyFromThing(payload, thing);
            return(payload);
        }
Ejemplo n.º 2
0
        public static DevicePayload FromDevice(Device device)
        {
            var item = new DevicePayload();

            ThingPayload.CopyFromThing(item, device);
            LogicableItemUtils.CopyFromLogicable(item, device);
            return(item);
        }
Ejemplo n.º 3
0
 public static void CopyFromThing(ThingPayload payload, Thing thing)
 {
     payload.referenceId      = thing.ReferenceId.ToString();
     payload.prefabHash       = thing.PrefabHash;
     payload.prefabName       = thing.PrefabName;
     payload.health           = thing.ThingHealth;
     payload.customName       = thing.IsCustomName ? thing.CustomName : null;
     payload.accessState      = thing.AccessState;
     payload.slotReferenceIds = ThingPayload.GetSlotReferenceIds(thing);
 }
Ejemplo n.º 4
0
 public static ThingPayload FromThingByType(Thing thing)
 {
     if (thing is Device)
     {
         return(DevicePayload.FromDevice((Device)thing));
     }
     if (thing is Item)
     {
         return(ItemPayload.FromItem((Item)thing));
     }
     return(ThingPayload.FromThing(thing));
 }
Ejemplo n.º 5
0
        public static ThingPrefabPayload FromGame()
        {
            var item = new ThingPrefabPayload();

            item.things = new Dictionary <string, ThingPayload>();

            foreach (Thing thing in Thing.AllPrefabs)
            {
                var payload = ThingPayload.FromThing(thing);
                item.things[thing.name] = payload;
            }

            return(item);
        }
Ejemplo n.º 6
0
        public static ItemPayload FromItem(Item item)
        {
            var payload = new ItemPayload();

            ThingPayload.CopyFromThing(payload, item);
            var slot = item.ParentSlot;

            if (slot != null)
            {
                payload.parentSlotReferenceId = slot.Parent.ReferenceId.ToString();
                payload.parentSlotId          = slot.SlotId;
            }
            payload.quantityText = item.GetQuantityText();
            return(payload);
        }
Ejemplo n.º 7
0
            public static ThingPayload FromThing(Thing prefab)
            {
                var item = new ThingPayload();

                item.name = prefab.name;
                item.hash = prefab.GetPrefabHash;

                if (prefab is IQuantity quantity)
                {
                    item.stackSize = (int)quantity.GetMaxQuantity;
                }
                else
                {
                    item.stackSize = 1;
                }

                if (prefab is INutrition nutrition)
                {
                    item.nutrition = Nutrition.FromINutrition(nutrition);
                }

                if (prefab is Ice ice)
                {
                    item.meltable = Meltable.FromIce(ice);
                }

                if (prefab is ILogicable iLogicable)
                {
                    item.logicTypes = LogicTypes.FromILogicable(iLogicable);
                }

                // TODO: Paintable

                item.temperatureLimits = TemperatureLimits.FromThing(prefab);

                if (prefab.Slots.Count > 0)
                {
                    item.slots = SlotsFromThing(prefab);
                }

                if (prefab is Item thingItem)
                {
                    item.createdReagents = ReagentsFromItem(thingItem);
                }

                if (prefab is Ore ore)
                {
                    item.spawnedGases = SpawnedGasFromOre(ore);
                }

                if (prefab.HasModeState && prefab.ModeStrings != null)
                {
                    item.modes = new List <string>(prefab.ModeStrings);
                }

                if (prefab is IConstructionKit kit)
                {
                    item.constructs = ConstructsFromKit(kit);
                }

                item.flags = FlagsFromThing(prefab);

                return(item);
            }