Beispiel #1
0
 private void UpdateOnChanged(RoomBehavior util)
 {
     if (Changed != null)
     {
         Changed(util);
     }
 }
Beispiel #2
0
 public void BehaviorsFromJson(JToken behaviorsToken)
 {
     foreach (JToken behaviorToken in behaviorsToken)
     {
         int          roomId   = (int)behaviorToken["Room"];
         string       type     = (string)behaviorToken["Behavior"];
         RoomBehavior behavior = PrototypeManager.RoomBehavior.Get(type);
         this[roomId].DesignateRoomBehavior(behavior.Clone());
     }
 }
Beispiel #3
0
        public bool UndesignateRoomBehavior(RoomBehavior roomBehavior)
        {
            // Just uninstalling.
            if (RoomBehaviors == null)
            {
                return(false);
            }

            RoomBehaviors.Remove(roomBehavior.Type);

            return(true);
        }
Beispiel #4
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.
        }
Beispiel #5
0
        /// <summary>
        /// Copy Constructor -- don't call this directly, unless we never
        /// do ANY sub-classing. Instead use Clone(), which is more virtual.
        /// </summary>
        /// <param name="other"><see cref="RoomBehavior"/> being cloned.</param>
        private RoomBehavior(RoomBehavior other)
        {
            Type        = other.Type;
            Name        = other.Name;
            typeTags    = new HashSet <string>(other.typeTags);
            description = other.description;

            Parameters = new Parameter(other.Parameters);

            if (other.EventActions != null)
            {
                EventActions = other.EventActions.Clone();
            }

            if (other.contextMenuLuaActions != null)
            {
                contextMenuLuaActions = new List <ContextMenuLuaAction>(other.contextMenuLuaActions);
            }

            if (other.funcRoomValidation != null)
            {
                funcRoomValidation = (Func <Room, bool>)other.funcRoomValidation.Clone();
            }

            if (other.requiredFurniture != null)
            {
                requiredFurniture = new List <FurnitureRequirement>(other.requiredFurniture);
            }

            if (other.ControlledFurniture != null)
            {
                ControlledFurniture = new Dictionary <string, List <Furniture> >(other.ControlledFurniture);
            }

            LocalizationCode       = other.LocalizationCode;
            UnlocalizedDescription = other.UnlocalizedDescription;
        }
Beispiel #6
0
        public bool DesignateRoomBehavior(RoomBehavior objInstance)
        {
            if (objInstance == null)
            {
                return(false);
            }

            if (RoomBehaviors.ContainsKey(objInstance.Type))
            {
                return(false);
            }

            if (objInstance.IsValidRoom(this) == false)
            {
                UnityDebugger.Debugger.LogError("Tile", "Trying to assign a RoomBehavior to a room that isn't valid!");
                return(false);
            }

            objInstance.Control(this);

            RoomBehaviors.Add(objInstance.Type, objInstance);

            return(true);
        }