コード例 #1
0
        public override void Do(VolatileObject target)
        {
            // VolatileObject in this case will always be a VolatileModule object
            VolatileModule module = target as VolatileModule;

            // Electricity
            module.energyProduction += energyIn;

            // Integrity
            module.structuralIntegrity += structuralIntegrityIn;

            // Pressurisation
            //module.pressurisation.Value += pressurisationIn;
            module.pressurisationGasses.AddResources(pressurisationGassesIn.ToArray());

            // Distribution
            // Set up the resourcesOut list
            resourcesOut = new List <ResourceStack>();
            // Get the remaining resources after the attempt to add them may not successfully add them all.
            resourcesOut.AddRange(module.Inventory.AddResources(resourcesIn.ToArray()));

            if (resourcesOut.Count > 0)
            {
                // If any resourcesOut have been added, the source module needs to be updated again to show the update of resources back into their inventory
                sourceHardpoint.Request(new UpdateModuleRequest()
                {
                    source = source, sourceHardpoint = sourceHardpoint, sequence = sequence, resourcesIn = resourcesOut
                });
            }
        }
コード例 #2
0
 public UpdateDecorator(VolatileObject target)
 {
     this.target = target;
 }