Exemplo n.º 1
0
        public RoamingJobState(Vector3Int pos, Colony colony, string objectiveType, IRoamingJobObjective settings = null)
        {
            Position      = pos;
            RoamObjective = objectiveType;
            Colony        = colony;

            if (settings == null)
            {
                RoamingJobSettings = RoamingJobManager.GetCallbacks(objectiveType);
            }
            else
            {
                RoamingJobSettings = settings;
            }

            Initialize();
        }
Exemplo n.º 2
0
        public static void OnTryChangeBlockUser(ModLoader.OnTryChangeBlockData d)
        {
            if (d.CallbackState == ModLoader.OnTryChangeBlockData.ECallbackState.Cancelled)
            {
                return;
            }

            IRoamingJobObjective roamingJobObjective = null;
            Colony colony = null;

            if (d.RequestOrigin.AsPlayer != null &&
                d.RequestOrigin.AsPlayer.ID.type != NetworkID.IDType.Server &&
                d.RequestOrigin.AsPlayer.ID.type != NetworkID.IDType.Invalid &&
                d.RequestOrigin.AsPlayer.ActiveColony != null)
            {
                colony = d.RequestOrigin.AsPlayer.ActiveColony;
            }

            if (d.RequestOrigin.AsColony != null)
            {
                colony = d.RequestOrigin.AsColony;
            }

            if (colony != null)
            {
                if (d.TypeNew.ItemIndex == ColonyBuiltIn.ItemTypes.AIR.Id)
                {
                    RemoveObjective(colony, d.Position);
                }
                else if (ItemTypes.TryGetType(d.TypeNew.ItemIndex, out ItemTypes.ItemType item))
                {
                    if (ObjectiveCallbacks.TryGetValue(item.Name, out roamingJobObjective))
                    {
                        RegisterRoamingJobState(colony, new RoamingJobState(d.Position, colony, roamingJobObjective.ItemIndex, roamingJobObjective));
                    }
                    else if (!string.IsNullOrEmpty(item.ParentType) && ObjectiveCallbacks.TryGetValue(item.ParentType, out roamingJobObjective))
                    {
                        RegisterRoamingJobState(colony, new RoamingJobState(d.Position, colony, roamingJobObjective.ItemIndex, roamingJobObjective));
                    }
                }
            }
        }
Exemplo n.º 3
0
 public static void RegisterObjectiveType(IRoamingJobObjective objective)
 {
     ObjectiveCallbacks[objective.ItemIndex] = objective;
 }