예제 #1
0
 private void _StoreConsumablesRefs(ServiceLocator.ID id, CommandReferences cRef, Command cmd)
 {
     foreach (Thing t in cmd.consumables)
     {
         cRef.consumableRefs.Add(_objIntModel.ClosestThingOfTypeInOOC(id, t.type));
     }
 }
예제 #2
0
 public Task_UnstowThing(MP4_Task queuedTask, ServiceLocator.ID id, Equipment_Base eqpt, Command cmd, CommandReferences cRef) : base(TaskType.Scheduled_Pauseable, queuedTask)
 {
     playerID       = id;
     this.installer = eqpt;
     this.cmd       = cmd;
     this.cRef      = cRef;
 }
예제 #3
0
 public Task_EjectThing(MP4_Task queuedTask, ServiceLocator.ID id, Equipment_Base ejector, Command cmd, CommandReferences cRef) : base(TaskType.Scheduled_Pauseable, queuedTask)
 {
     playerID     = id;
     this.ejector = ejector;
     this.cmd     = cmd;
     this.cRef    = cRef;
 }
예제 #4
0
 public void ConsumeContinuous(Command cmd, CommandReferences cRef)
 {
     if (cmd.reagents.Length > 0)
     {
         foreach (Reagent r in cmd.reagents)
         {
             foreach (Item_Base i in cRef.reagentRefs)
             {
                 if (r.reagentType.type == i.type)
                 {
                     i.capacity += r.continuousCostPerSecond * Time.deltaTime;
                 }
             }
         }
     }
 }
예제 #5
0
 public void ConsumeDiscrete(Command cmd, CommandReferences cRef)
 {
     if (cmd.reagents.Length > 0)
     {
         foreach (Reagent r in cmd.reagents)
         {
             foreach (Item_Base i in cRef.reagentRefs)
             {
                 if (r.reagentType.type == i.type)
                 {
                     i.capacity += r.discreteActionCost;
                 }
             }
         }
     }
 }
예제 #6
0
    private void _StoreReagentsRefs(ServiceLocator.ID id, Equipment_Base e, CommandReferences cRef, Command cmd)
    {
        if (cmd.reagents.Length == 0)
        {
            return;
        }
        else
        {
            // For some check the equipment's stowed list
            if (cmd.action == ServiceLocator.Actions.Weld || cmd.action == ServiceLocator.Actions.Power || cmd.action == ServiceLocator.Actions.Charge || cmd.action == ServiceLocator.Actions.Eject || cmd.action == ServiceLocator.Actions.Unstow)
            {
                //    For actions that require that reagents be internally present:
                //    -Check to see if a given stowed item meets the requirements of the cmd
                //    - Then make sure that the ref for the cmd doesn't already contain a redundant one
                //     - If that's good, then add the given stowed item to the refs

                for (int i = 0; i < e.stowed.Count; i++)
                {
                    for (int j = 0; j < cmd.reagents.Length; j++)
                    {
                        if (e.stowed[i].type == cmd.reagents[j].reagentType.type)
                        {
                            List <ServiceLocator.ThingType> storedReferenceTypes = new List <ServiceLocator.ThingType>();
                            foreach (Item_Base iB in cRef.reagentRefs)
                            {
                                storedReferenceTypes.Add(iB.type);
                            }

                            if (!storedReferenceTypes.Contains(cmd.reagents[j].reagentType.type))
                            {
                                Debug.Log("Item of type of reagent specified type stored. Item is " + e.stowed[i].name.ToString());
                                cRef.reagentRefs.Add(e.stowed[i] as Item_Base);
                            }
                        }
                    }
                }
            }
            // For others, check the area
            else
            {
                foreach (Reagent r in cmd.reagents)
                {
                    cRef.reagentRefs.Add(_objIntModel.ClosestThingOfTypeInOOC(id, r.reagentType.type) as Item_Base);
                }
            }
        }
    }
예제 #7
0
        public static ColonyPanel GetInstance(StaticDataStore staticData, EntityState selectedEntity)
        {
            ColonyPanel instance;

            if (selectedEntity.CmdRef == null)
            {
                selectedEntity.CmdRef = CommandReferences.CreateForEntity(_state.Game, selectedEntity.Entity);
            }
            if (!_state.LoadedWindows.ContainsKey(typeof(ColonyPanel)))
            {
                instance = new ColonyPanel(staticData, selectedEntity);
                instance.HardRefresh();
                return(instance);
            }
            instance = (ColonyPanel)_state.LoadedWindows[typeof(ColonyPanel)];
            instance._selectedEntity = selectedEntity;

            return(instance);
        }
예제 #8
0
    private void _StoreTargetRefs(ServiceLocator.ID id, Equipment_Base e, CommandReferences cRef, Command cmd)
    {
        if (cmd.action == ServiceLocator.Actions.Charge || cmd.action == ServiceLocator.Actions.Eject || cmd.action == ServiceLocator.Actions.Unstow)
        {
            foreach (Thing t in e.stowed)
            {
                Item_Base      iB = t as Item_Base;
                Equipment_Base eB = t as Equipment_Base;

                if (iB != null)
                {
                    if (iB.type == cmd.target)
                    {
                        Debug.Log("CREF!!! --- " + cmd.target.ToString() + " should match with " + iB.type.ToString());

                        cRef.target = iB;

                        Debug.Log("CREF!!! --- " + cRef.target.ToString());
                        break;
                    }
                }
                else if (eB != null)
                {
                    if (eB.type == cmd.target)
                    {
                        Debug.Log("CREF!!! --- " + cmd.target.ToString() + " should match with " + eB.type.ToString());

                        cRef.target = eB;

                        Debug.Log("CREF!!! --- " + cRef.target.ToString());
                        break;
                    }
                }
            }
        }
        else
        {
            cRef.target = _objIntModel.ClosestThingOfTypeInOOC(id, cmd.target);
        }
    }
예제 #9
0
    private void _ParseInteractionCommands(ServiceLocator.ID id)
    {
        if (id == ServiceLocator.ID.p0)
        {
            Debug.Assert(_objIntModel.p0_InteractableInterested.cat == ServiceLocator.ThingCategory.Equipment ||
                         _objIntModel.p0_InteractableInterested.cat == ServiceLocator.ThingCategory.Stations,
                         "Attempting to parse menu for command-less interactiveCategory");

            if (_objIntModel.p0_InteractableInterested.cat == ServiceLocator.ThingCategory.Equipment)
            {
                //Debug.Log("ControllerMenuEqpt in the equipment track");
                Equipment_Base e = _objIntModel.p0_InteractableInterested as Equipment_Base;
                if (e != null)
                {
                    //Debug.Log(this.GetType().ToString() + " identified as eqpt");
                    Dictionary <Command, CommandReferences> commandDict = new Dictionary <Command, CommandReferences>();
                    Dictionary <int, Command> seqDict = new Dictionary <int, Command>();

                    for (int i = 0; i < e.possibleCommands.Length; i++)
                    {
                        Debug.Log(this.GetType().ToString() + " in the for loop. possiblecommands length is " + e.possibleCommands.Length + ".");

                        bool commandPermissible = false;

                        if (_ReqdReagentConditionsMet(id, e, e.possibleCommands[i]) &&
                            _ReqdConsumablesPresent(id, e.possibleCommands[i]) &&
                            _IntendedTargetPresent(id, e, e.possibleCommands[i]) &&
                            _SpecialConditions(id, e, e.possibleCommands[i]))
                        {
                            commandPermissible = true;
                            Debug.Log("Command is permissible");
                        }

                        if (commandPermissible)
                        {
                            CommandReferences cRef = ScriptableObject.Instantiate <CommandReferences>(Resources.Load <CommandReferences>("CommandReference/CommandReference"));
                            _StoreConsumablesRefs(id, cRef, e.possibleCommands[i]);
                            _StoreReagentsRefs(id, e, cRef, e.possibleCommands[i]);
                            _StoreTargetRefs(id, e, cRef, e.possibleCommands[i]);
                            Debug.Log("CHecking if CREF EXISTS?!?!?!? " + cRef.target.ToString());

                            commandDict.Add(e.possibleCommands[i], cRef);
                            seqDict.Add(seqDict.Count, e.possibleCommands[i]);
                        }
                    }

                    //Debug.Log("SeqDict count is " + seqDict.Count);
                    Command cancel = Resources.Load <Command>("Command/ExitMenu");
                    //Debug.Log(cancel.name);

                    CommandReferences cancelCRef = ScriptableObject.Instantiate(Resources.Load <CommandReferences>("CommandReference/CommandReference"));
                    commandDict.Add(cancel, cancelCRef);
                    //Debug.Log("SeqDict count is " + seqDict.Count);

                    seqDict.Add(seqDict.Count, cancel);
                    //Debug.Log("SeqDict count is " + seqDict.Count);

                    //Debug.Log(commandDict.Count + " " + seqDict.Count);

                    //Debug.Log("Reagent Refs has :" + cRef.reagentRefs.Count);
                    _eqptMenuModel.SetCommands(id, e, commandDict, seqDict);
                }
            }
            else if (_objIntModel.p0_InteractableInterested.cat == ServiceLocator.ThingCategory.Stations)
            {
                //Stn code
            }
        }
        else
        {
            //Mirror for p1
        }
    }