Пример #1
0
    /// <summary>
    /// This function is called to update the furniture. This will also trigger EventsActions.
    /// This checks if the furniture is a PowerConsumer, and if it does not have power it cancels its job.
    /// </summary>
    /// <param name="deltaTime">The time since the last update was called.</param>
    public void Update(float deltaTime)
    {
        if (PowerConnection != null && PowerConnection.IsPowerConsumer && HasPower() == false)
        {
            if (JobCount() > 0)
            {
                PauseJobs();
            }

            return;
        }

        if (pausedJobs.Count > 0)
        {
            ResumeJobs();
        }

        // TODO: some weird thing happens
        if (EventActions != null)
        {
            // updateActions(this, deltaTime);
            EventActions.Trigger("OnUpdate", this, deltaTime);
        }

        if (IsWorkshop)
        {
            workshop.Update(deltaTime);
        }

        if (Animation != null)
        {
            Animation.Update(deltaTime);
        }
    }
Пример #2
0
        /// <summary>
        /// Reads the prototype from the specified JObject.
        /// </summary>
        /// <param name="jsonProto">The JProperty containing the prototype.</param>
        public void ReadJsonPrototype(JProperty jsonProto)
        {
            Type = jsonProto.Name;
            JToken innerJson = jsonProto.Value;

            typeTags                = new HashSet <string>(PrototypeReader.ReadJsonArray <string>(innerJson["TypeTags"]));
            LocalizationName        = PrototypeReader.ReadJson(LocalizationName, innerJson["LocalizationName"]);
            LocalizationDescription = PrototypeReader.ReadJson(LocalizationDescription, innerJson["LocalizationDescription"]);

            EventActions.ReadJson(innerJson["EventActions"]);
            contextMenuLuaActions = PrototypeReader.ReadContextMenuActions(innerJson["ContextMenuActions"]);

            if (innerJson["Parameters"] != null)
            {
                Parameters.FromJson(innerJson["Parameters"]);
            }

            if (innerJson["Requirements"] != null)
            {
                ReadJsonRequirements((JArray)innerJson["Requirements"]);
            }

            if (innerJson["Optional"] != null)
            {
                ReadJsonRequirements((JArray)innerJson["Optional"], true);
            }
        }
Пример #3
0
 private ChargeBeeApi()
 {
     Addon               = new AddonActions(this);
     Address             = new AddressActions(this);
     Card                = new CardActions(this);
     Comment             = new CommentActions(this);
     Coupon              = new CouponActions(this);
     CouponCode          = new CouponCodeActions(this);
     CreditNote          = new CreditNoteActions(this);
     Customer            = new CustomerActions(this);
     Estimate            = new EstimateActions(this);
     Event               = new EventActions(this);
     HostedPage          = new HostedPageActions(this);
     Invoice             = new InvoiceActions(this);
     Order               = new OrderActions(this);
     PaymentSource       = new PaymentSourceActions(this);
     Plan                = new PlanActions(this);
     PortalSession       = new PortalSessionActions(this);
     ResourceMigration   = new ResourceMigrationActions(this);
     SiteMigrationDetail = new SiteMigrationDetailActions(this);
     Subscription        = new SubscriptionActions(this);
     TimeMachine         = new TimeMachineActions(this);
     Transaction         = new TransactionActions(this);
     UnbilledCharge      = new UnbilledChargeActions(this);
 }
Пример #4
0
    /// <summary>
    /// Used to transfer registere actions to new object.
    /// </summary>
    /// <returns>A new object copy of this.</returns>
    public EventActions Clone()
    {
        EventActions evt = new EventActions();

        evt.actionsList = new Dictionary <string, List <string> >(actionsList);

        return(evt);
    }
Пример #5
0
        void Start()
        {
            text        = GetComponentInChildren <Text>();
            textFadeout = text.GetComponent <TextFadeout>();
            actions     = GameObject.FindObjectOfType <EventActions>();

            SetLines(FirstTalk.ListLines);
        }
Пример #6
0
 /// <summary>
 /// This function is called to update the room behavior. This will also trigger EventsActions.
 /// </summary>
 /// <param name="deltaTime">The time since the last update was called.</param>
 public void Update(float deltaTime)
 {
     if (EventActions != null)
     {
         // updateActions(this, deltaTime);
         EventActions.Trigger("OnUpdate", this, deltaTime);
     }
 }
Пример #7
0
 public void Update(float deltaTime)
 {
     // TODO: some weird thing happens
     if (EventActions != null)
     {
         // updateActions(this, deltaTime);
         EventActions.Trigger("OnUpdate", this, deltaTime);
     }
 }
Пример #8
0
    /// <summary>
    /// This function is called to update the furniture. This will also trigger EventsActions.
    /// This checks if the furniture is a PowerConsumer, and if it does not have power it cancels its job.
    /// </summary>
    /// <param name="deltaTime">The time since the last update was called.</param>
    public void FixedFrequencyUpdate(float deltaTime)
    {
        // requirements from components (gas, ...)
        bool canFunction = true;

        BuildableComponent.Requirements newRequirements = BuildableComponent.Requirements.None;
        foreach (BuildableComponent component in components)
        {
            bool componentCanFunction = component.CanFunction();
            canFunction &= componentCanFunction;

            // if it can't function, collect all stuff it needs (power, gas, ...) for icon signalization
            if (!componentCanFunction)
            {
                newRequirements |= component.Needs;
            }
        }

        // requirements were changed, force update of status icons
        if (Requirements != newRequirements)
        {
            Requirements = newRequirements;
            OnIsOperatingChanged(this);
        }

        IsOperating = canFunction;

        if (canFunction == false)
        {
            if (prevUpdatePowerOn)
            {
                EventActions.Trigger("OnPowerOff", this, deltaTime);
            }

            Jobs.PauseAll();
            prevUpdatePowerOn = false;
            return;
        }

        prevUpdatePowerOn = true;
        Jobs.ResumeAll();

        if (EventActions != null)
        {
            EventActions.Trigger("OnUpdate", this, deltaTime);
        }

        foreach (BuildableComponent component in components)
        {
            component.FixedFrequencyUpdate(deltaTime);
        }

        if (Animation != null)
        {
            Animation.Update(deltaTime);
        }
    }
Пример #9
0
        /// <summary>
        /// Reads the prototype room behavior from XML.
        /// </summary>
        /// <param name="readerParent">The XML reader to read from.</param>
        public void ReadXmlPrototype(XmlReader readerParent)
        {
            Type = readerParent.GetAttribute("type");

            XmlReader reader = readerParent.ReadSubtree();

            while (reader.Read())
            {
                switch (reader.Name)
                {
                    case "Name":
                        reader.Read();
                        Name = reader.ReadContentAsString();
                        break;
                    case "TypeTag":
                        reader.Read();
                        typeTags.Add(reader.ReadContentAsString());
                        break;
                    case "Description":
                        reader.Read();
                        description = reader.ReadContentAsString();
                        break;
                    case "Requirements":
                        ReadXmlRequirements(reader);
                        break;
                    case "Optional":
                        ReadXmlRequirements(reader, true);
                        break;
                    case "Action":
                        XmlReader subtree = reader.ReadSubtree();
                        EventActions.ReadXml(subtree);
                        subtree.Close();
                        break;
                    case "ContextMenuAction":
                        contextMenuLuaActions.Add(new ContextMenuLuaAction
                            {
                                LuaFunction = reader.GetAttribute("FunctionName"),
                                Text = reader.GetAttribute("Text"),
                                RequireCharacterSelected = bool.Parse(reader.GetAttribute("RequireCharacterSelected")),
                                DevModeOnly = bool.Parse(reader.GetAttribute("DevModeOnly") ?? "false")
                            });
                        break;
                    case "Params":
                        ReadXmlParams(reader);  // Read in the Param tag
                        break;
                    case "LocalizationCode":
                        reader.Read();
                        LocalizationCode = reader.ReadContentAsString();
                        break;
                    case "UnlocalizedDescription":
                        reader.Read();
                        UnlocalizedDescription = reader.ReadContentAsString();
                        break;
                }
            }
        }
Пример #10
0
    /// <summary>
    /// Deconstructs the utility.
    /// </summary>
    public void Deconstruct()
    {
        if (Tile.Utilities != null)
        {
            Jobs.CancelAll();
        }

        // Just unregister our grid, it will get reregistered if there are any other utilities on this grid
        World.Current.PowerNetwork.RemoveGrid(Grid);

        // We call lua to decostruct
        EventActions.Trigger("OnUninstall", this);
        Tile.UnplaceUtility(this);

        if (Removed != null)
        {
            Removed(this);
        }

        Deconstruct deconstructOrder = GetOrderAction <Deconstruct>();

        if (deconstructOrder != null)
        {
            foreach (KeyValuePair <string, int> inv in deconstructOrder.Inventory)
            {
                World.Current.InventoryManager.PlaceInventoryAround(Tile, new Inventory(inv.Key, inv.Value));
            }
        }

        // We should inform our neighbours that they have just lost a neighbour.
        // Just trigger their OnChangedCallback.
        foreach (Tile neighbor in Tile.GetNeighbours())
        {
            if (neighbor.Utilities != null && neighbor.Utilities.ContainsKey(this.Type))
            {
                Utility neighborUtility = neighbor.Utilities[this.Type];
                if (neighborUtility.Changed != null)
                {
                    neighborUtility.Changed(neighborUtility);
                }

                if (neighborUtility.Grid == this.Grid)
                {
                    neighborUtility.Grid = new UtilityGrid();
                }

                neighborUtility.UpdateGrid(neighborUtility);
                neighborUtility.Grid.Split();
            }
        }

        // At this point, no DATA structures should be pointing to us, so we
        // should get garbage-collected.
    }
Пример #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RoomBehavior"/> class.
        /// </summary>
        public RoomBehavior()
        {
            EventActions = new EventActions();

            contextMenuLuaActions = new List <ContextMenuLuaAction>();
            Parameters            = new Parameter();
            typeTags            = new HashSet <string>();
            funcRoomValidation  = DefaultIsValidRoom;
            requiredFurniture   = new List <FurnitureRequirement>();
            ControlledFurniture = new Dictionary <string, List <Furniture> >();
        }
Пример #12
0
    /// TODO: Implement object rotation
    /// <summary>
    /// Initializes a new instance of the <see cref="Utility"/> class.
    /// </summary>
    public Utility()
    {
        Tint         = new Color(1f, 1f, 1f, .25f);
        EventActions = new EventActions();

        contextMenuLuaActions = new List <ContextMenuLuaAction>();
        Parameters            = new Parameter();
        Jobs     = new BuildableJobs(this);
        typeTags = new HashSet <string>();
        tileTypeBuildPermissions = new HashSet <string>();
    }
Пример #13
0
    /// <summary>
    /// This function is called to update the furniture animation in lua.
    /// This will be called every frame and should be used carefully.
    /// </summary>
    /// <param name="deltaTime">The time since the last update was called.</param>
    public void EveryFrameUpdate(float deltaTime)
    {
        if (EventActions != null)
        {
            EventActions.Trigger("OnFastUpdate", this, deltaTime);
        }

        foreach (BuildableComponent component in components)
        {
            component.EveryFrameUpdate(deltaTime);
        }
    }
Пример #14
0
    /// <summary>
    /// This function is called to update the furniture animation in lua.
    /// This will be called every frame and should be used carefully.
    /// </summary>
    /// <param name="deltaTime">The time since the last update was called.</param>
    public void EveryFrameUpdate(float deltaTime)
    {
        if (EventActions != null)
        {
            EventActions.Trigger("OnFastUpdate", this, deltaTime);
        }

        foreach (var cmp in components)
        {
            cmp.EveryFrameUpdate(deltaTime);
        }
    }
Пример #15
0
    /// <summary>
    /// Deconstructs the utility.
    /// </summary>
    public void Deconstruct()
    {
        int x = Tile.X;
        int y = Tile.Y;

        if (Tile.Utilities != null)
        {
            Jobs.CancelAll();
        }

        // We call lua to decostruct
        EventActions.Trigger("OnUninstall", this);
        Tile.UnplaceUtility(this);

        if (Removed != null)
        {
            Removed(this);
        }

        if (deconstructInventory != null)
        {
            foreach (Inventory inv in deconstructInventory)
            {
                inv.MaxStackSize = PrototypeManager.Inventory.Get(inv.Type).maxStackSize;
                World.Current.InventoryManager.PlaceInventoryAround(Tile, inv.Clone());
            }
        }

        // We should inform our neighbours that they have just lost a
        // neighbour regardless of type.
        // Just trigger their OnChangedCallback.
        for (int xpos = x - 1; xpos < x + 2; xpos++)
        {
            for (int ypos = y - 1; ypos < y + 2; ypos++)
            {
                Tile tileAt = World.Current.GetTileAt(xpos, ypos, Tile.Z);
                if (tileAt != null && tileAt.Utilities != null)
                {
                    foreach (Utility neighborUtility in tileAt.Utilities.Values)
                    {
                        if (neighborUtility.Changed != null)
                        {
                            neighborUtility.Changed(neighborUtility);
                        }
                    }
                }
            }
        }

        // At this point, no DATA structures should be pointing to us, so we
        // should get garbage-collected.
    }
Пример #16
0
 public AccountBase(IDataService dataService,
     EventActions eventActions,
     BusinessActions businessActions,
     PromotionActions promoActions,
     PromotionInstanceActions promoInstanceActions,
     ILogger log)
 {
     this.DataService = dataService;
     this.EventActions = eventActions;
     this.BusinessActions = businessActions;
     this.PromotionActions = promoActions;
     this.PromotionInstanceActions = promoInstanceActions;
     this.Log = log;
 }
Пример #17
0
        /// <summary>
        /// Deconstructs the room behavior.
        /// </summary>
        public void Deconstruct(RoomBehavior roomBehavior)
        {
            // We call lua to decostruct
            EventActions.Trigger("OnUninstall", this);
            Room.UndesignateRoomBehavior(roomBehavior);

            if (Removed != null)
            {
                Removed(this);
            }

            // At this point, no DATA structures should be pointing to us, so we
            // should get garbage-collected.
        }
Пример #18
0
    public void OnClicked()
    {
        // These names should actually be something like "button_my" in order to be localized.
        // However, just to make sure, we replace this to avoid any problems.
        buttonName = buttonName.Replace(" ", "_");
        EventActions dialogEvents = transform.GetComponentInParent <ModDialogBox>().events;

        Debug.ULogChannel("ModDialogBox", "Calling On" + buttonName + "Clicked function");

        if (dialogEvents.HasEvent("On" + buttonName + "Clicked") == true)
        {
            Debug.ULogChannel("ModDialogBox", "Found On" + buttonName + "Clicked event");
            dialogEvents.Trigger <ModDialogBox>("On" + buttonName + "Clicked", transform.GetComponentInParent <ModDialogBox>());
        }
    }
Пример #19
0
 /// <summary>
 /// Constructeur principal
 /// </summary>
 private FormsManager()
 {
     AnimationManagerContainer = new AnimationManagerContainer();
     ResourcesManager          = new ResourcesManager();
     DialogManager             = new DialogManager();
     TriggerManager            = new TriggerManager();
     ItemManager      = new ItemManager();
     CharacterManager = new CharacterManager();
     VariableManager  = new VariableManager();
     CoordsManager    = new CoordsManager();
     EventManager     = new EventManager();
     EventActions     = new EventActions();
     ScriptCondition  = new ScriptCondition();
     ScriptLoop       = new ScriptLoop();
     ScriptChoice     = new ScriptChoice();
 }
Пример #20
0
    /// TODO: Implement object rotation
    /// <summary>
    /// Initializes a new instance of the <see cref="Furniture"/> class.
    /// </summary>
    public Furniture()
    {
        Tint          = Color.white;
        JobSpotOffset = Vector2.zero;
        VerticalDoor  = false;
        EventActions  = new EventActions();

        contextMenuLuaActions = new List <ContextMenuLuaAction>();
        furnParameters        = new Parameter();
        jobs     = new List <Job>();
        typeTags = new HashSet <string>();
        funcPositionValidation   = DefaultIsValidPosition;
        tileTypeBuildPermissions = new HashSet <string>();
        Height = 1;
        Width  = 1;
    }
Пример #21
0
    public override void HandleEvent(OptionTag oType)
    {
        base.HandleEvent(oType);

        switch (oType)
        {
        case (OptionTag.Land):
            if (characters[0].getStat("Piloting") + Random.Range(0, 3) > 6)
            {
                LogEntry(characters[0].Name + " has successfully landed on " + subject + " allowing the party to scavange for resources.");
                EventActions.gainRandomResource(this);
                EventActions.gainRandomResource(this);
                GameControllerScript.instance.locationState = LocationState.Land;
            }
            else
            {
                LogEntry("As " + characters[0].Name + " descends into the atmosphere, an electrical storm knocks out the " + GameControllerScript.instance.party.ship.Name + "'s engines, causing it to crash.");
                GameControllerScript.instance.party.ship.Damage(5);

                EventActions.loseResource(this, "Fuel");
                GameControllerScript.instance.locationState = LocationState.Land;
            }
            break;

        case (OptionTag.Scan):
            if (Random.Range(0, 100) > 60)
            {
                LogEntry(characters[1].Name + " scans " + subject + " and determines it is rich with minerals.");
                EventActions.gainRandomResource(this);
            }
            else
            {
                LogEntry("The atmosphere of " + subject + " is creating too much interference to properly scan.");
            }
            EventActions.loseResource(this, "Fuel");
            break;

        case (OptionTag.Bypass):

            LogEntry(characters[2].Name + " guides the ship around the planet.");
            EventActions.loseResource(this, "Fuel");
            GameControllerScript.instance.LightYearsToEOU -= 2;
            break;
        }

        GameControllerScript.instance.currentSituation = null;
    }
Пример #22
0
    public override void HandleEvent(OptionTag oType)
    {
        base.HandleEvent(oType);

        switch (oType)
        {
        case (OptionTag.Recruit):
            if (characters[1].getStat("Mind") + Random.Range(0, 10) > 6)
            {
                LogEntry(characters[1].Name + " convices " + characters[0].Name + " to join the party with a triumphant speech.");
                GameControllerScript.instance.party.addPartyMember(characters[0]);
                LogEntry(characters[0].Name + " joins the party!");
            }
            else
            {
                LogEntry("AWKWARD! " + characters[0].Name + " rejects the invitation from " + characters[1].Name + " to join the party.");
            }
            break;

        case (OptionTag.Gossip):

            LogEntry(characters[2].Name + " learns about a nearby planet rich with resources from " + characters[0].Name);
            EventActions.gainRandomResource(this);
            GameControllerScript.instance.LightYearsToEOU -= 2;
            break;

        case (OptionTag.Intimidate):
            if (characters[3].getStat("Strength") > Random.Range(0, 10))
            {
                LogEntry(characters[0].Name + " backs away as " + characters[3].Name + " threatens them into giving up supplies.");
                EventActions.gainRandomResource(this);
            }
            else
            {
                LogEntry(characters[0].Name + " stands up to " + characters[3].Name + ", causing them to give up supplies in embarassment.");
                EventActions.loseRandomResource(this);
            }
            break;
        }
        LogEntry("The crew fires up the ship and heads back into space.");
        GameControllerScript.instance.locationState = LocationState.Space;

        GameControllerScript.instance.currentSituation = null;
    }
Пример #23
0
    /// <summary>
    /// This function is called to update the furniture. This will also trigger EventsActions.
    /// This checks if the furniture is a PowerConsumer, and if it does not have power it cancels its job.
    /// </summary>
    /// <param name="deltaTime">The time since the last update was called.</param>
    public void FixedFrequencyUpdate(float deltaTime)
    {
        // requirements from components (gas, ...)
        bool canFunction = true;

        foreach (var cmp in components)
        {
            canFunction &= cmp.CanFunction();
        }

        IsOperating = DoesntNeedOrHasPower && canFunction;

        if ((PowerConnection != null && PowerConnection.IsPowerConsumer && DoesntNeedOrHasPower == false) ||
            canFunction == false)
        {
            if (prevUpdatePowerOn)
            {
                EventActions.Trigger("OnPowerOff", this, deltaTime);
            }

            Jobs.PauseAll();
            prevUpdatePowerOn = false;
            return;
        }

        prevUpdatePowerOn = true;
        Jobs.ResumeAll();

        // TODO: some weird thing happens
        if (EventActions != null)
        {
            EventActions.Trigger("OnUpdate", this, deltaTime);
        }

        foreach (var cmp in components)
        {
            cmp.FixedFrequencyUpdate(deltaTime);
        }

        if (Animation != null)
        {
            Animation.Update(deltaTime);
        }
    }
Пример #24
0
    /// <summary>
    /// Reads the prototype from the specified JObject.
    /// </summary>
    /// <param name="jsonProto">The JProperty containing the prototype.</param>
    public void ReadJsonPrototype(JProperty jsonProto)
    {
        Type = jsonProto.Name;
        JToken innerJson = jsonProto.Value;

        typeTags                = new HashSet <string>(PrototypeReader.ReadJsonArray <string>(innerJson["TypeTags"]));
        LocalizationName        = PrototypeReader.ReadJson(LocalizationName, innerJson["LocalizationName"]);
        LocalizationDescription = PrototypeReader.ReadJson(LocalizationDescription, innerJson["LocalizationDescription"]);

        tileTypeBuildPermissions = new HashSet <string>(PrototypeReader.ReadJsonArray <string>(innerJson["tileTypeBuildPermissions"]));

        orderActions          = PrototypeReader.ReadOrderActions(innerJson["OrderActions"]);
        contextMenuLuaActions = PrototypeReader.ReadContextMenuActions(innerJson["ContextMenuActions"]);
        EventActions.ReadJson(innerJson["EventActions"]);
        if (innerJson["Parameters"] != null)
        {
            Parameters.FromJson(innerJson["Parameters"]);
        }
    }
Пример #25
0
        public void Control(Room room)
        {
            this.Room = room;
            HashSet <Tile> allTiles = room.GetInnerTiles();

            allTiles.UnionWith(room.GetBoundaryTiles());

            foreach (FurnitureRequirement requirement in requiredFurniture)
            {
                string furnitureKey = requirement.type ?? requirement.typeTag;
                ControlledFurniture.Add(furnitureKey, new List <Furniture>());
                foreach (Tile tile in allTiles.Where(tile => (tile.Furniture != null && (tile.Furniture.Type == requirement.type || tile.Furniture.HasTypeTag(requirement.typeTag)))))
                {
                    ControlledFurniture[furnitureKey].Add(tile.Furniture);
                }
            }

            EventActions.Trigger("OnControl", this);
        }
Пример #26
0
    public void Update(float deltaTime)
    {
        if (PowerConnection != null && PowerConnection.IsPowerConsumer && HasPower() == false)
        {
            if (JobCount() > 0)
            {
                CancelJobs();
            }

            return;
        }

        // TODO: some weird thing happens
        if (EventActions != null)
        {
            // updateActions(this, deltaTime);
            EventActions.Trigger("OnUpdate", this, deltaTime);
        }
    }
Пример #27
0
        public void Control(Room room) 
        {
            this.Room = room;
            List<Tile> innerTiles = room.GetInnerTiles();
            List<Tile> borderTiles = room.GetBorderingTiles();

            List<Tile> allTiles = innerTiles.Union(borderTiles).ToList();

            foreach (NestedObjectRequirement requirement in requiredNestedObject)
            {
                string nestedObjectKey = requirement.type ?? requirement.typeTag;
                ControlledNestedObject.Add(nestedObjectKey, new List<NestedObject>());
                foreach (Tile tile in allTiles.FindAll(tile => (tile.NestedObject != null && (tile.NestedObject.Type == requirement.type || tile.NestedObject.HasTypeTag(requirement.typeTag))))) 
                {
                    ControlledNestedObject[nestedObjectKey].Add(tile.NestedObject);
                }
            }

            EventActions.Trigger("OnControl", this);
        }
Пример #28
0
        public void Control(Room room)
        {
            this.Room = room;
            List <Tile> innerTiles  = room.GetInnerTiles();
            List <Tile> borderTiles = room.GetBorderingTiles();

            List <Tile> allTiles = innerTiles.Union(borderTiles).ToList();

            foreach (FurnitureRequirement requirement in requiredFurniture)
            {
                string furnitureKey = requirement.type ?? requirement.typeTag;
                ControlledFurniture.Add(furnitureKey, new List <Furniture>());
                foreach (Tile tile in allTiles.FindAll(tile => (tile.Furniture != null && (tile.Furniture.Type == requirement.type || tile.Furniture.HasTypeTag(requirement.typeTag)))))
                {
                    ControlledFurniture[furnitureKey].Add(tile.Furniture);
                }
            }

            EventActions.Trigger("OnControl", this);
        }
Пример #29
0
    /// <summary>
    /// Initializes a new instance of the <see cref="Furniture"/> class.
    /// This constructor is used to create prototypes and should never be used ouside the Prototype Manager.
    /// </summary>
    public Furniture()
    {
        Tint         = Color.white;
        VerticalDoor = false;
        EventActions = new EventActions();

        contextMenuLuaActions = new List <ContextMenuLuaAction>();
        Parameters            = new Parameter();
        Jobs     = new BuildableJobs(this);
        typeTags = new HashSet <string>();
        tileTypeBuildPermissions = new HashSet <string>();
        PathfindingWeight        = 1f;
        PathfindingModifier      = 0f;
        Height           = 1;
        Width            = 1;
        CanRotate        = false;
        Rotation         = 0f;
        DragType         = "single";
        LinksToNeighbour = string.Empty;
        components       = new HashSet <BuildableComponent>();
    }
Пример #30
0
    public void Deconstruct()
    {
        int  x                = Tile.X;
        int  y                = Tile.Y;
        int  fwidth           = 1;
        int  fheight          = 1;
        bool linksToNeighbour = false;

        if (Tile.Furniture != null)
        {
            Furniture furniture = Tile.Furniture;
            fwidth           = furniture.Width;
            fheight          = furniture.Height;
            linksToNeighbour = furniture.LinksToNeighbour;
            furniture.CancelJobs();
        }

        // We call lua to decostruct
        EventActions.Trigger("OnUninstall", this);

        // Update thermalDiffusifity to default value
        World.Current.temperature.SetThermalDiffusivity(Tile.X, Tile.Y, Temperature.defaultThermalDiffusivity);

        Tile.UnplaceFurniture();

        if (Removed != null)
        {
            Removed(this);
        }

        // Do we need to recalculate our rooms?
        if (RoomEnclosure)
        {
            Room.DoRoomFloodFill(Tile);
        }

        ////World.current.InvalidateTileGraph();

        if (World.Current.tileGraph != null)
        {
            World.Current.tileGraph.RegenerateGraphAtTile(Tile);
        }

        // We should inform our neighbours that they have just lost a
        // neighbour regardless of objectType.
        // Just trigger their OnChangedCallback.
        if (linksToNeighbour == true)
        {
            for (int xpos = x - 1; xpos < x + fwidth + 1; xpos++)
            {
                for (int ypos = y - 1; ypos < y + fheight + 1; ypos++)
                {
                    Tile t = World.Current.GetTileAt(xpos, ypos);
                    if (t != null && t.Furniture != null && t.Furniture.Changed != null)
                    {
                        t.Furniture.Changed(t.Furniture);
                    }
                }
            }
        }

        // At this point, no DATA structures should be pointing to us, so we
        // should get garbage-collected.
    }
Пример #31
0
    public void ReadXmlPrototype(XmlReader readerParent)
    {
        ObjectType = readerParent.GetAttribute("objectType");

        XmlReader reader = readerParent.ReadSubtree();

        while (reader.Read())
        {
            switch (reader.Name)
            {
            case "Name":
                reader.Read();
                Name = reader.ReadContentAsString();
                break;

            case "TypeTag":
                reader.Read();
                typeTags.Add(reader.ReadContentAsString());
                break;

            case "Description":
                reader.Read();
                description = reader.ReadContentAsString();
                break;

            case "MovementCost":
                reader.Read();
                MovementCost = reader.ReadContentAsFloat();
                break;

            case "Width":
                reader.Read();
                Width = reader.ReadContentAsInt();
                break;

            case "Height":
                reader.Read();
                Height = reader.ReadContentAsInt();
                break;

            case "LinksToNeighbours":
                reader.Read();
                LinksToNeighbour = reader.ReadContentAsBoolean();
                break;

            case "EnclosesRooms":
                reader.Read();
                RoomEnclosure = reader.ReadContentAsBoolean();
                break;

            case "CanReplaceFurniture":
                replaceableFurniture.Add(reader.GetAttribute("typeTag").ToString());
                break;

            case "DragType":
                reader.Read();
                DragType = reader.ReadContentAsString();
                break;

            case "BuildingJob":
                float jobTime = float.Parse(reader.GetAttribute("jobTime"));

                List <Inventory> invs = new List <Inventory>();

                XmlReader inventoryReader = reader.ReadSubtree();

                while (inventoryReader.Read())
                {
                    if (inventoryReader.Name == "Inventory")
                    {
                        // Found an inventory requirement, so add it to the list!
                        invs.Add(new Inventory(
                                     inventoryReader.GetAttribute("objectType"),
                                     int.Parse(inventoryReader.GetAttribute("amount")),
                                     0));
                    }
                }

                Job j = new Job(
                    null,
                    ObjectType,
                    FurnitureActions.JobComplete_FurnitureBuilding,
                    jobTime,
                    invs.ToArray(),
                    Job.JobPriority.High);
                j.JobDescription = "job_build_" + ObjectType + "_desc";
                World.Current.SetFurnitureJobPrototype(j, this);
                break;

            case "Action":
                XmlReader subtree = reader.ReadSubtree();
                EventActions.ReadXml(subtree);
                subtree.Close();
                break;

            case "ContextMenuAction":
                contextMenuLuaActions.Add(new ContextMenuLuaAction
                {
                    LuaFunction = reader.GetAttribute("FunctionName"),
                    Text        = reader.GetAttribute("Text"),
                    RequiereCharacterSelected = bool.Parse(reader.GetAttribute("RequiereCharacterSelected"))
                });
                break;

            case "IsEnterable":
                isEnterableAction = reader.GetAttribute("FunctionName");
                break;

            case "GetSpriteName":
                getSpriteNameAction = reader.GetAttribute("FunctionName");
                break;

            case "JobSpotOffset":
                JobSpotOffset = new Vector2(
                    int.Parse(reader.GetAttribute("X")),
                    int.Parse(reader.GetAttribute("Y")));
                break;

            case "JobSpawnSpotOffset":
                jobSpawnSpotOffset = new Vector2(
                    int.Parse(reader.GetAttribute("X")),
                    int.Parse(reader.GetAttribute("Y")));
                break;

            case "Power":
                reader.Read();
                powerValue = reader.ReadContentAsFloat();

                // TODO: Connection = new Connection();
                // TODO: Connection.ReadPrototype(reader);
                break;

            case "Params":
                ReadXmlParams(reader);  // Read in the Param tag
                break;

            case "LocalizationCode":
                reader.Read();
                LocalizationCode = reader.ReadContentAsString();
                break;

            case "UnlocalizedDescription":
                reader.Read();
                UnlocalizedDescription = reader.ReadContentAsString();
                break;
            }
        }
    }
Пример #32
0
 public static NBrightInfo ProcessEventProvider(EventActions eventaction, NBrightInfo nbrightInfo)
 {
     return ProcessEventProvider(eventaction, nbrightInfo, "");
 }
Пример #33
0
        public static NBrightInfo ProcessEventProvider(EventActions eventaction, NBrightInfo nbrightInfo, String eventinfo)
        {
            var rtnInfo = nbrightInfo;
            var pluginData = new PluginData(nbrightInfo.PortalId);
            var provList = pluginData.GetEventsProviders();

            foreach (var d in provList)
            {
                var prov = d.Value;
                ObjectHandle handle = null;
                var cachekey = prov.PortalId + "*" + prov.GetXmlProperty("genxml/textbox/assembly") + "*" + prov.GetXmlProperty("genxml/textbox/namespaceclass");
                handle = (ObjectHandle)Utils.GetCache(cachekey);
                if (handle == null) handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass"));
                if (handle != null)
                {
                    var eventprov = (EventInterface) handle.Unwrap();
                    if (eventprov != null)
                    {
                        if (eventaction == EventActions.ValidateCartBefore)
                        {
                            rtnInfo = eventprov.ValidateCartBefore(nbrightInfo);
                        }
                        else if (eventaction == EventActions.ValidateCartAfter)
                        {
                            rtnInfo = eventprov.ValidateCartAfter(nbrightInfo);
                        }
                        else if (eventaction == EventActions.ValidateCartItemBefore)
                        {
                            rtnInfo = eventprov.ValidateCartItemBefore(nbrightInfo);
                        }
                        else if (eventaction == EventActions.ValidateCartItemAfter)
                        {
                            rtnInfo = eventprov.ValidateCartItemAfter(nbrightInfo);
                        }
                        else if (eventaction == EventActions.AfterCartSave)
                        {
                            rtnInfo = eventprov.AfterCartSave(nbrightInfo);
                        }
                        else if (eventaction == EventActions.AfterCategorySave)
                        {
                            rtnInfo = eventprov.AfterCategorySave(nbrightInfo);
                        }
                        else if (eventaction == EventActions.AfterProductSave)
                        {
                            rtnInfo = eventprov.AfterProductSave(nbrightInfo);
                        }
                        else if (eventaction == EventActions.AfterSavePurchaseData)
                        {
                            rtnInfo = eventprov.AfterSavePurchaseData(nbrightInfo);
                        }
                        else if (eventaction == EventActions.BeforeOrderStatusChange)
                        {
                            rtnInfo = eventprov.BeforeOrderStatusChange(nbrightInfo);
                        }
                        else if (eventaction == EventActions.AfterOrderStatusChange)
                        {
                            rtnInfo = eventprov.AfterOrderStatusChange(nbrightInfo);
                        }
                        else if (eventaction == EventActions.BeforePaymentOK)
                        {
                            rtnInfo = eventprov.BeforePaymentOK(nbrightInfo);
                        }
                        else if (eventaction == EventActions.AfterPaymentOK)
                        {
                            rtnInfo = eventprov.AfterPaymentOK(nbrightInfo);
                        }
                        else if (eventaction == EventActions.BeforePaymentFail)
                        {
                            rtnInfo = eventprov.BeforePaymentFail(nbrightInfo);
                        }
                        else if (eventaction == EventActions.AfterPaymentFail)
                        {
                            rtnInfo = eventprov.AfterPaymentFail(nbrightInfo);
                        }
                        else if (eventaction == EventActions.BeforeSendEmail)
                        {
                            rtnInfo = eventprov.BeforeSendEmail(nbrightInfo,eventinfo);
                        }
                        else if (eventaction == EventActions.AfterSendEmail)
                        {
                            rtnInfo = eventprov.AfterSendEmail(nbrightInfo,eventinfo);
                        }

                    }
                }
            }
            return rtnInfo;
        }