Пример #1
0
 public static void ValidateBlockID(string id, PowerObject powerObject)
 {
     if (validblockIDs.ContainsKey(id) == false)
     {
         validblockIDs.Add(id, powerObject);
     }
 }
Пример #2
0
        public static void MarkObject(EPowerType powerType, Vector3Int pos, PowerObject powerObject)
        {
            switch (powerType)
            {
            case EPowerType.Battery:
                if (batteries.ContainsKey(pos) == false)
                {
                    batteries.Add(pos, powerObject as Battery);
                }
                break;

            case EPowerType.Generator:
                if (generators.ContainsKey(pos) == false)
                {
                    generators.Add(pos, powerObject as Generator);
                }
                break;

            case EPowerType.Machine:
                if (machines.ContainsKey(pos) == false)
                {
                    machines.Add(pos, powerObject as Machine);
                }
                break;
            }
        }
Пример #3
0
 public static bool GetPowerObject(string id, out PowerObject powerObject)
 {
     powerObject = null;
     if (IsPowerBlock(id))
     {
         if (validblockIDs[id].GetType().BaseType == typeof(Generator))
         {
             Generator tmp = (Generator)validblockIDs[id] as Generator;
             powerObject = new Generator(tmp.Name, tmp.GetMaxPower(), tmp.Generates);
         }
         if (validblockIDs[id].GetType().BaseType == typeof(Machine))
         {
             Machine tmp = (Machine)validblockIDs[id] as Machine;
             powerObject = new Machine(tmp.Name, tmp.GetMaxPower(), tmp.PowerUsage);
         }
         if (validblockIDs[id].GetType().BaseType == typeof(Battery))
         {
             Battery tmp = (Battery)validblockIDs[id] as Battery;
             powerObject = new Battery(tmp.Name, tmp.GetMaxPower());
         }
         return(true);
     }
     return(false);
 }