예제 #1
0
        public bool GetRandomNodeForLocation(string groupPath, TimeOfDay timeOfDay, out ActionNodeState nodeState)
        {
            bool foundNode = false;

            nodeState = null;
            List <ActionNodeState> nodeStates = null;

            if (GetNodesForLocation(groupPath, out nodeStates))
            {
                List <int> numbersTried = new List <int> ();
                //try random numbers until we have none left
                while (numbersTried.Count <= nodeStates.Count)
                {
                    int randomIndex = UnityEngine.Random.Range(0, nodeStates.Count);
                    //get another number that we haven't tried yet
                    while (numbersTried.Contains(randomIndex))
                    {
                        randomIndex = UnityEngine.Random.Range(0, nodeStates.Count);
                    }
                    numbersTried.Add(randomIndex);
                    //check to see if the node's time of day lines up
                    ActionNodeState checkState = nodeStates [randomIndex];
                    if (Flags.Check((uint)checkState.RoutineHours, (uint)timeOfDay, Flags.CheckType.MatchAny))
                    {
                        foundNode = true;
                        nodeState = checkState;
                        break;
                    }
                }
            }
            return(foundNode);
        }
예제 #2
0
 public void Activate(MissionOriginType originType, string originName)
 {
     //if we're not completed and we're not active...
     if (!State.ObjectivesCompleted && !Flags.Check((uint)State.Status, (uint)MissionStatus.Active, Flags.CheckType.MatchAny))
     {
         State.OriginType    = originType;
         State.OriginName    = originName;
         State.TimeActivated = WorldClock.AdjustedRealTime;
         State.Status        = MissionStatus.Active;
         //if we have a mission to force-complete, do that here
         if (!string.IsNullOrEmpty(State.ForceCompleteOnStart))
         {
             Missions.Get.ForceCompleteMission(State.ForceCompleteOnStart);
         }
         //create and activate the first objective
         for (int i = 0; i < FirstObjectives.Count; i++)
         {
             FirstObjectives [i].OnActivateMission();
         }
         Player.Get.AvatarActions.ReceiveAction((AvatarAction.MissionActivate), WorldClock.AdjustedRealTime);
         Player.Get.AvatarActions.ReceiveAction((AvatarAction.MissionUpdated), WorldClock.AdjustedRealTime);
         GUIManager.PostGainedItem(this);
         State.GetPlayerAttention = true;
         Save();
     }
 }
예제 #3
0
 public void OnTrigger()
 {
     if (Flags.Check((uint)ContainerFillTime.OnTrigger, (uint)State.FillTime, Flags.CheckType.MatchAny))
     {
         TryToFillContainer(false);
     }
 }
예제 #4
0
        public override void OnInitialized()
        {
            if (State.Activated)
            {
                gameObject.tag = Globals.TagGroundStone;
                if (State.Moved)
                {
                    MovableRock.localPosition = MovedPosition;
                }
                else
                {
                    MovableRock.localPosition = Vector3.zero;
                }
            }
            else
            {
                BookStatus status = BookStatus.None;
                if (Books.GetBookStatus(State.BookName, out status) && Flags.Check((int)status, (int)BookStatus.Read, Flags.CheckType.MatchAny))
                {
                    State.Activated = true;
                    gameObject.tag  = Globals.TagGroundStone;
                }
                else
                {
                    gameObject.tag = Globals.TagNonInteractive;
                    Player.Get.AvatarActions.Subscribe(AvatarAction.BookRead, new ActionListener(BookRead));
                }
            }

            worlditem.OnPlayerUse += OnPlayerUse;
        }
예제 #5
0
        public MovementNode GetNodeNearest(Vector3 position, LocationTerrainType locationType, bool interior, int occupationFlags)
        {
            MovementNode closest      = MovementNode.Empty;
            MovementNode m            = MovementNode.Empty;
            float        closestSoFar = Mathf.Infinity;
            float        current      = 0f;
            bool         checkFlags   = (occupationFlags < Int32.MaxValue);

            for (int i = 0; i < State.MovementNodes.Count; i++)
            {
                m = State.MovementNodes [i];
                if (!checkFlags || Flags.Check(occupationFlags, m.OccupationFlags, Flags.CheckType.MatchAny))
                {
                    current = Vector3.Distance(position, m.Position);
                    if (current < 2f)
                    {
                        return(closest = m);

                        break;
                    }
                    else if (current < closestSoFar)
                    {
                        closestSoFar = current;
                        closest      = m;
                    }
                }
            }
            if (MovementNode.IsEmpty(m))
            {
                Debug.Log("Returning empty in closest from " + name);
            }
            return(closest);
        }
예제 #6
0
 public void OnOpenContainer()
 {
     if (Flags.Check((uint)ContainerFillTime.OnOpen, (uint)State.FillTime, Flags.CheckType.MatchAny))
     {
         TryToFillContainer(true);
     }
 }
예제 #7
0
        public void IgnoreObjective()
        {
            if (State.Completed)
            {
                return;
            }

            State.Status |= MissionStatus.Active;            //ignoring is equivlant to activating it
            State.Status |= MissionStatus.Ignored;
            State.Status &= ~MissionStatus.Dormant;
            if (State.Type == ObjectiveType.Optional ||
                (State.Type == ObjectiveType.RequiredOnceActive && !Flags.Check((uint)State.Status, (uint)MissionStatus.Active, Flags.CheckType.MatchAny)))
            {
                if (State.CompleteOnIgnore)
                {
                    State.Completed = true;
                }
            }
            else                //if we ignore an objective an it's required
                                //we've failed
            {
                State.Completed = true;
                State.Status   |= MissionStatus.Failed;
                State.Status   &= ~MissionStatus.Dormant;
            }
            //refresh - force lower objectives to activate
            TryToComplete();
        }
예제 #8
0
        public void OnIntersectItemOfInterest()
        {
            if (!IsInUse)
            {
                return;
            }

            if (!string.IsNullOrEmpty(Extensions.AddComponentOnUse))
            {
                while (SkillSphere.ItemsOfInterest.Count > 0)
                {
                    IItemOfInterest ioi = SkillSphere.ItemsOfInterest.Dequeue();
                    //see if this is what we want
                    if (ioi != null)
                    {
                        if (!(Extensions.IgnoreCaster && ioi.IOIType == ItemOfInterestType.Player && ioi.player == Player.Local))
                        {
                            if (Flags.Check((uint)ioi.IOIType, (uint)Usage.TargetItemsOfInterest, Flags.CheckType.MatchAny) && ioi.HasAtLeastOne(Usage.TargetWIScriptNames))
                            {
                                OnIntersectTarget(ioi);
                            }
                        }
                    }
                }
            }
        }
예제 #9
0
        public void Refresh()
        {
            Debug.Log("Mission: Refreshing mission " + name);
            if (mDestroyed)
            {
                Debug.Log("Destroyed, returning");
                return;
            }

            if (mRefreshingMission || mTryingToCompleteMission)
            {
                Debug.Log("Already trying to refresh mission, returning");
                return;
            }

            if (!Flags.Check((uint)State.Status, (uint)MissionStatus.Active, Flags.CheckType.MatchAny))
            {
                Debug.Log("Mission was not active, returning");
                return;
            }

            if (State.ObjectivesCompleted)
            {
                Debug.Log("Objectives completed, returning");
                return;
            }

            mRefreshingMission = true;
            StartCoroutine(RefreshOverTime());
        }
예제 #10
0
        public void RefreshNoteProps( )
        {
            MissionStatus objectiveStatus = MissionStatus.Dormant;

            if (Missions.Get.ObjectiveStatusByName("Friends", "SpeakToKara", ref objectiveStatus))
            {
                if (Flags.Check((uint)MissionStatus.Completed, (uint)objectiveStatus, Flags.CheckType.MatchAny))
                {
                    worlditem.RemoveFromGame();
                    return;
                }
            }

            mExamineInfo.LocationsToReveal.Clear();

            if (Missions.Get.ObjectiveStatusByName("Legacy", "GiveFigurine", ref objectiveStatus) &&
                Flags.Check((uint)MissionStatus.Completed, (uint)objectiveStatus, Flags.CheckType.MatchAny))
            {
                State.ObservatoryNote = false;
            }

            if (State.ObservatoryNote)
            {
                mExamineInfo.StaticExamineMessage = ObservatoryNote;
                MobileReference observatoryLocation = new MobileReference(State.ObservatoryPath);
                mExamineInfo.LocationsToReveal.Add(observatoryLocation);
            }
            else
            {
                mExamineInfo.StaticExamineMessage = BalloonCampNote;
                MobileReference balloonCampLocation = new MobileReference(State.BalloonCampPath);
                mExamineInfo.LocationsToReveal.Add(balloonCampLocation);
            }
        }
예제 #11
0
        public void SetTemplate(WorldLightTemplate newTemplate)
        {
            Template = newTemplate;

            mTargetHeatIntensity = -1f;
            mTargetBaseRange     = -1f;
            mTargetSpotRange     = -1f;
            mTargetBaseIntensity = -1f;
            mTargetSpotIntensity = -1f;
            mMasterBrightness    = -1f;

            if (Globals.MissionDevelopmentMode)
            {
                SpotlightTop.enabled    = false;
                SpotlightBottom.enabled = false;
                SpotlightLeft.enabled   = false;
                SpotlightRight.enabled  = false;
                SpotlightFront.enabled  = false;
                SpotlightBack.enabled   = false;
            }
            else
            {
                SpotlightTop.enabled    = Flags.Check((uint)Template.Spotlights, (uint)SpotlightDirection.Top, Flags.CheckType.MatchAny);
                SpotlightBottom.enabled = Flags.Check((uint)Template.Spotlights, (uint)SpotlightDirection.Bottom, Flags.CheckType.MatchAny);
                SpotlightLeft.enabled   = Flags.Check((uint)Template.Spotlights, (uint)SpotlightDirection.Left, Flags.CheckType.MatchAny);
                SpotlightRight.enabled  = Flags.Check((uint)Template.Spotlights, (uint)SpotlightDirection.Right, Flags.CheckType.MatchAny);
                SpotlightFront.enabled  = Flags.Check((uint)Template.Spotlights, (uint)SpotlightDirection.Front, Flags.CheckType.MatchAny);
                SpotlightBack.enabled   = Flags.Check((uint)Template.Spotlights, (uint)SpotlightDirection.Back, Flags.CheckType.MatchAny);
            }

            Color     color  = Colors.Get.ByName(Template.Color1);
            Texture2D cookie = LightManager.Get.Cookie(Template.Cookie);

            for (int i = 0; i < mSpotlights.Count; i++)
            {
                Light spotlight = mSpotlights [i];
                spotlight.color     = color;
                spotlight.intensity = 0f;
                spotlight.range     = 0f;
                spotlight.spotAngle = Template.SpotlightAngle;
                spotlight.cookie    = cookie;
            }

            TargetSpotIntensity = Template.SpotlightIntensity;
            TargetSpotRange     = Template.SpotlightRange;

            if (Globals.MissionDevelopmentMode)
            {
                BaseLight.enabled = false;
            }
            else
            {
                BaseLight.enabled = Template.BaseLight;
            }
            BaseLight.intensity = 0f;
            BaseLight.color     = color;
            TargetBaseRange     = Template.BaseRange;
            TargetBaseIntensity = Template.BaseIntensity;
        }
예제 #12
0
 public int ArmorLevel(WIMaterialType materialType)
 {
     if (Flags.Check((uint)MaterialTypes, (uint)materialType, Flags.CheckType.MatchAny))
     {
         return(BaseDamageProtection);
     }
     return(0);
 }
예제 #13
0
        public void Refresh(bool refreshNextObjectives)
        {
            if (!mHasSubscribed)              //get all the avatar actions that our scripts want to know about
            //then subscrube to them. this only needs to happen once, on startup
            {
                mSubscriptionListener = new ActionListener(Subscription);
                //get a hashset (to avoid duplicates)
                HashSet <AvatarAction> subscriptions = new HashSet <AvatarAction> ();
                foreach (ObjectiveScript script in State.Scripts)
                {
                    if (script != null)
                    {
                        foreach (AvatarAction action in script.Subscriptions)
                        {
                            subscriptions.Add(action);
                        }
                    }
                    else
                    {
                        //this should never happen
                        Debug.LogError("SCRIPT WAS NULL IN OBJECTIVE " + State.FileName);
                    }
                }
                //add them to the list (I may remove this later, for now it's handy
                State.Subscriptions.Clear();
                State.Subscriptions.AddRange(subscriptions);
                foreach (AvatarAction subscription in State.Subscriptions)
                {
                    Player.Get.AvatarActions.Subscribe((subscription), mSubscriptionListener);
                }

                mHasSubscribed = true;
            }

            //do a sanity check on our objective status
            if (Flags.Check((uint)MissionStatus.Active, (uint)State.Status, Flags.CheckType.MatchAny))
            {
                //remove dormant from the status, just in case
                State.Status &= ~MissionStatus.Dormant;
            }

            if (refreshNextObjectives)
            {
                foreach (MissionObjective nextObjective in NextObjectives)
                {
                    if (nextObjective != null)
                    {
                        nextObjective.Refresh(true);
                    }
                    else
                    {
                        Debug.LogError("OBJECTIVE WAS NULL IN MISSION " + name);
                    }
                }
            }
        }
예제 #14
0
        protected override bool CheckSubstitutionRule()
        {
            MissionStatus status = MissionStatus.Dormant;

            if (Missions.Get.MissionStatusByName(MissionName, ref status))
            {
                return(Flags.Check((uint)status, (uint)MissionStatus.Active, Flags.CheckType.MatchAny));
            }
            return(false);
        }
예제 #15
0
 public void OnAddedToPlayerInventory()
 {
     if (Flags.Check((uint)ContainerFillTime.OnAddToPlayerInventory, (uint)State.FillTime, Flags.CheckType.MatchAny))
     {
         TryToFillContainer(false);
     }
     //now that we're being added to the inventory
     //this script needs to be removed
     Finish();
 }
예제 #16
0
 public virtual bool Check(WIFlags otherFlags)
 {
     return                                    // (true);//TEMP
            (Flags.Check(Occupation, otherFlags.Occupation, Flags.CheckType.MatchAny) &&
             Flags.Check(Alignment, otherFlags.Alignment, Flags.CheckType.MatchAny) &&
             Flags.Check(Faction, otherFlags.Faction, Flags.CheckType.MatchAny) &&
             Flags.Check(Region, otherFlags.Region, Flags.CheckType.MatchAny) &&
             Flags.Check(Subject, otherFlags.Subject, Flags.CheckType.MatchAny) &&
             Flags.Check(Wealth, otherFlags.Wealth, Flags.CheckType.MatchAny));
 }
예제 #17
0
        public override void PushSelectedObjectToViewer()
        {
            //turn this into a string builder
            Color         plantColor = Colors.ColorFromString(mSelectedObject.CommonName, 100);
            List <string> detailText = new List <string>();

            mExamineInfo.Clear();

            Skill            examineSkill      = null;
            GenericWorldItem dopplegangerProps = null;

            if (Skills.Get.SkillByName("Gathering", out examineSkill))
            {
                bool showDetails = false;
                Plants.Examine(mSelectedObject, mExamineInfo);
                detailText.Add("Viewing season " + WorldClock.TimeOfYearToString(SelectedSeasonality));
                if (Flags.Check((uint)mSelectedObject.EncounteredTimesOfYear, (uint)SelectedSeasonality, Flags.CheckType.MatchAny) ||
                    examineSkill.State.NormalizedUsageLevel > Plants.MinimumGatheringSkillToRevealBasicProps)
                {
                    showDetails                   = true;
                    dopplegangerProps             = mPlantDoppleganger;
                    dopplegangerProps.Subcategory = mSelectedObject.Name;
                }
                else
                {
                    detailText.Add("(You don't know what this plant looks like during this time of year.)");
                }
                detailText.Add("_");
                for (int i = 0; i < mExamineInfo.Count; i++)
                {
                    if (examineSkill.State.NormalizedUsageLevel > mExamineInfo[i].RequiredSkillUsageLevel)
                    {
                        detailText.Add(mExamineInfo[i].StaticExamineMessage);
                    }
                    else
                    {
                        detailText.Add(mExamineInfo[i].ExamineMessageOnFail);
                    }
                }
                string finalDetailText = detailText.JoinToString("\n");
                GUIDetailsPage.Get.DisplayDetail(
                    this,
                    mSelectedObject.CommonName,
                    finalDetailText,
                    "PlantIcon",
                    Mats.Get.IconsAtlas,
                    plantColor,
                    Color.white,
                    dopplegangerProps);
                if (showDetails)
                {
                    GUIDetailsPage.Get.DisplayDopplegangerButton("Next Season", "OnClickNextSeason", gameObject);
                }
            }
        }
예제 #18
0
 protected void CheckAgainst(Collider treeCollider, Collider otherCollider, TreeColliderFlags flags)
 {
     if (Flags.Check((uint)flags, (uint)TreeColliderFlags.Rustle, Flags.CheckType.MatchAny))
     {
         if (!mRustling)
         {
             mRustling = true;
             StartCoroutine(RustleOverTime(otherCollider));
         }
     }
 }
예제 #19
0
        public void RefreshPathMarkerProps(bool setPosition)
        {
            if (!mInitialized)
            {
                return;
            }

            if (HasPathMarkerProps)
            {
                if (setPosition)
                {
                    worlditem.ActiveState = WIActiveState.Active;
                    mHit.feetPosition     = mProps.Position;
                    mHit.overhangHeight   = 4.0f;
                    mHit.groundedHeight   = 5.0f;
                    mHit.ignoreWorldItems = true;                                                            //we want path markers to appear below people / signs / etc
                    mHit.feetPosition.y   = GameWorld.Get.TerrainHeightAtInGamePosition(ref mHit);
                    worlditem.tr.position = mHit.feetPosition;
                    worlditem.tr.rotation = Quaternion.Euler(0f, mProps.Rotation.y, 0f);
                    //update the props position based on the new in-game height
                    Props.Position = mHit.feetPosition;
                }

                Visitable visitable = worlditem.Get <Visitable>();
                visitable.State = Props.Visitable;

                Revealable revealable = worlditem.Get <Revealable>();
                revealable.State = Props.Revealable;

                //we only care about other items if we're a path origin
                //OR if we're the terminal of an active path
                if (Flags.Check((uint)PathMarkerType.PathOrigin, (uint)mProps.Type, Flags.CheckType.MatchAny) || (IsActive && IsTerminal))
                {
                    visitable.Trigger.enabled = true;
                    if (visitable.Trigger.VisitableCollider != null)
                    {
                        SphereCollider sc = visitable.Trigger.VisitableCollider as SphereCollider;
                        sc.radius = Globals.PathOriginTriggerRadius;
                    }
                    else
                    {
                        SphereCollider sc = visitable.Trigger.gameObject.AddComponent <SphereCollider>();
                        sc.radius = Globals.PathOriginTriggerRadius;
                        visitable.Trigger.VisitableCollider = sc;
                    }
                    worlditem.State = "CrossMarker";
                }
                else
                {
                    visitable.Trigger.enabled = false;
                    worlditem.State           = "PathMarker";
                }
            }
        }
예제 #20
0
 public bool Check(CharacterFlags anyOfThese)
 {
     return(Flags.Check(CharacterBodyLayout, anyOfThese.CharacterBodyLayout, Flags.CheckType.MatchAny) &&
            Flags.Check(Alignment, anyOfThese.Alignment, Flags.CheckType.MatchAny) &&
            Flags.Check(Ethnicity, anyOfThese.Ethnicity, Flags.CheckType.MatchAny) &&
            Flags.Check(Faction, anyOfThese.Faction, Flags.CheckType.MatchAny) &&
            Flags.Check(Gender, anyOfThese.Gender, Flags.CheckType.MatchAny) &&
            Flags.Check(GeneralAge, anyOfThese.GeneralAge, Flags.CheckType.MatchAny) &&
            Flags.Check(Occupation, anyOfThese.Occupation, Flags.CheckType.MatchAny) &&
            Flags.Check(Region, anyOfThese.Region, Flags.CheckType.MatchAny));
 }
예제 #21
0
        public virtual bool IsObjectPermitted(WorldItem potentialOccupant, ReceptacleSettings settings)
        {
            if (State.Locked)
            {
                return(false);
            }

            if (potentialOccupant == null)
            {
                return(false);
            }

            if (((int)potentialOccupant.Size) > ((int)settings.MaxSize))
            {
                //TODO use Stacks size comparison, this is error prone
                Debug.Log("Too big");
                return(false);
            }

            if (settings.PermittedScripts.Count > 0)
            {
                if (!potentialOccupant.HasAtLeastOne(settings.PermittedScripts))
                {
                    return(false);
                }
            }
            if (settings.PermittedSubcats.Count > 0)
            {
                if (!settings.PermittedSubcats.Contains(potentialOccupant.Subcategory))
                {
                    return(false);
                }
            }
            if (settings.PermittedMaterials != WIMaterialType.None)
            {
                if (!Flags.Check((uint)settings.PermittedMaterials, (uint)potentialOccupant.Props.Global.MaterialType, Flags.CheckType.MatchAny))
                {
                    return(false);
                }
            }
            if (settings.PermittedItems.Count > 0)
            {
                foreach (string permittedItemName in settings.PermittedItems)
                {
                    if (!Stacks.Can.Stack(potentialOccupant, permittedItemName))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
예제 #22
0
        public void OnTriggerEnter(Collider other)
        {
            if (other.isTrigger)
            {
                return;
            }

            if (WorldItems.GetIOIFromCollider(other, out LastItemOfInterest) &&
                Flags.Check((uint)TriggeredBy, (uint)LastItemOfInterest.IOIType, Flags.CheckType.MatchAny))
            {
                trigger.TryToTrigger();
            }
        }
예제 #23
0
        public void OnAddedToGroup()
        {
            //see if there are any flags we need to inherit
            IStackOwner owner = null;

            if (worlditem.Group.HasOwner(out owner))
            {
                if (owner == Player.Local)
                {
                    //we've been added to the player inventory
                    //don't bother to fill
                    Finish();
                    return;
                }

                Structure structure = null;
                if (owner.IsWorldItem && owner.worlditem.Is <Structure> (out structure))
                {
                    State.Flags.Union(structure.State.StructureFlags);
                }
            }

            mIsFilling = false;
            worlditem.OnAddedToPlayerInventory += OnAddedToPlayerInventory;
            worlditem.OnModeChange             += OnModeChange;
            worlditem.OnVisible += OnVisible;
            worlditem.OnActive  += OnVisible;

            if (Flags.Check((uint)ContainerFillTime.OnDie, (uint)State.FillTime, Flags.CheckType.MatchAny))
            {
                Damageable damageable = null;
                if (worlditem.Is <Damageable> (out damageable))
                {
                    damageable.OnDie += OnDie;
                }
            }

            //if this is a character then we'll want to filter our flags with the character flags
            Character character = null;

            if (worlditem.Is <Character> (out character))
            {
                State.Flags.Union(character.State.Flags);
                character.OnAccessInventory += OnOpenContainer;
                if (character.HasBank)
                {
                    mBankToFill = character.InventoryBank;
                }
            }
        }
예제 #24
0
        public override void CheckIfCompleted()
        {
            BookStatus status = BookStatus.None;

            if (Books.GetBookStatus(BookName, out status))
            {
                if (Flags.Check((uint)status, (uint)CheckStatus, Flags.CheckType.MatchAny))
                {
                    HasCompleted = true;
                    Status      |= MissionStatus.Completed;
                }
            }
            FinishedChecking = true;
        }
예제 #25
0
        public void ActivateObjective(string objectiveName, MissionOriginType originType, string originName)
        {
            if (!Flags.Check((uint)State.Status, (uint)MissionStatus.Active, Flags.CheckType.MatchAny))
            {
                Activate(originType, originName);
            }
            MissionObjective objective = null;

            if (mObjectiveLookup.TryGetValue(objectiveName, out objective))
            {
                objective.ActivateObjective(ObjectiveActivation.Manual, originType, originName);
            }
            State.GetPlayerAttention = true;
            Save();
        }
예제 #26
0
        public bool CheckObjectiveStatus(double timeStamp)
        {
            MissionStatus objectiveStatusCheck = MissionStatus.Dormant;

            if (Missions.Get.ObjectiveStatusByName(MissionName, ObjectiveName, ref objectiveStatusCheck))
            {
                if (Flags.Check((uint)ObjectiveStatus, (uint)objectiveStatusCheck, Flags.CheckType.MatchAny))
                {
                    //we've hit the objective status check, set our convo now
                    Debug.Log("Objective " + ObjectiveName + " is of status " + ObjectiveStatus.ToString() + " so indress is changing to " + ConversationOnObjectiveStatus);
                    talkative.State.ConversationName = ConversationOnObjectiveStatus;
                }
            }
            return(true);
        }
예제 #27
0
        public bool BookRead(double timeStamp)
        {
            if (State.Activated)
            {
                return(true);
            }

            BookStatus status = BookStatus.None;

            if (Books.GetBookStatus(State.BookName, out status) && Flags.Check((int)status, (int)BookStatus.Read, Flags.CheckType.MatchAny))
            {
                State.Activated = true;
                gameObject.tag  = Globals.TagGroundStone;
            }
            return(true);
        }
예제 #28
0
        public override void OnInitialized()
        {
            bodyofwater = worlditem.GetComponent <BodyOfWater> ();

            bool          flooded = false;
            MissionStatus status  = MissionStatus.Dormant;

            if (Missions.Get.MissionStatusByName(MissionName, ref status))
            {
                if (Flags.Check((uint)MissionStatus.Dormant, (uint)status, Flags.CheckType.MatchAny))
                {
                    //if the mission hasn't started, water level is normal
                    //Debug.Log ("Mission status was dormant, water is flooded");
                    flooded = true;
                }
                else
                {
                    //if the mission has started OR been completed, water level is based on variable
                    if (Missions.Get.GetVariableValue(MissionName, VariableName) <= 0)
                    {
                        //Debug.Log ("Mission variable was less than or equal to zero, water is flooded");
                        flooded = true;
                    }
                }
            }

            mCurrentWaterLevel = 0f;

            if (flooded)
            {
                worlditem.OnVisible   += OnVisible;
                worlditem.OnInvisible += OnInvisible;
                TargetWaterLevel       = State.LakeWaterLevelHigh;
            }
            else
            {
                TargetWaterLevel = State.LakeWaterLevelNormal;
            }

            StartCoroutine(SetFlooded(flooded));

            if (flooded)
            {
                Debug.Log("Subscribing to mission variable change in behemoth dam");
                Player.Get.AvatarActions.Subscribe(AvatarAction.MissionVariableChange, new ActionListener(MissionVariableChange));
            }
        }
예제 #29
0
        //custom doppleganger script for plants
        public override GameObject GetDoppleganger(WorldItem item, Transform dopplegangerParent, string dopplegangerName, WIMode mode, string state, string subcat, float scaleMultiplier, TimeOfDay tod, TimeOfYear toy)
        {
            GameObject doppleganger = dopplegangerParent.gameObject.FindOrCreateChild(dopplegangerName).gameObject;
            Vector3    offset       = Vector3.zero;

            //we have a lookup based on season so this has to be in season form
            toy = WorldClock.TimeOfYearToSeason(toy);
            Plants.Get.InitializeWorldPlantGameObject(doppleganger, subcat, toy);
            if (Flags.Check((uint)mode, (uint)(WIMode.Stacked | WIMode.Selected | WIMode.Crafting | WIMode.Wear), Flags.CheckType.MatchAny))
            {
                WorldItems.AutoScaleDoppleganger(dopplegangerParent, doppleganger, item.BaseObjectBounds, ref scaleMultiplier, ref offset);
            }
            //TODO debug so this isn't necessary...
            offset.y = 0f;
            WorldItems.ApplyDopplegangerMode(item, doppleganger, mode, scaleMultiplier, offset);
            return(doppleganger);
        }
예제 #30
0
        public void Refresh()
        {
            if (MainColliderFlags == TreeColliderFlags.None || Flags.Check((uint)MainColliderFlags, (uint)TreeColliderFlags.Ignore, Flags.CheckType.MatchAny))
            {
                MainCollider.enabled = false;
            }
            else
            {
                MainCollider.enabled = true;
                MainCollider.radius  = MainRadius;
                MainCollider.height  = MainHeight;
                MainCollider.transform.localPosition = MainOffset;
                if (Flags.Check((uint)MainColliderFlags, (uint)TreeColliderFlags.Solid, Flags.CheckType.MatchAny))
                {
                    MainCollider.isTrigger        = false;
                    MainCollider.gameObject.layer = Globals.LayerNumObstacleTerrain;
                }
                else
                {
                    MainCollider.isTrigger        = true;
                    MainCollider.gameObject.layer = Globals.LayerNumTrigger;
                }
            }

            if (SecondaryColliderFlags == TreeColliderFlags.None || Flags.Check((uint)SecondaryColliderFlags, (uint)TreeColliderFlags.Ignore, Flags.CheckType.MatchAny))
            {
                SecondaryCollider.enabled = false;
            }
            else
            {
                SecondaryCollider.enabled = true;
                SecondaryCollider.radius  = SecondaryRadius;
                SecondaryCollider.height  = SecondaryHeight;
                SecondaryCollider.transform.localPosition = SecondaryOffset;
                if (Flags.Check((uint)SecondaryColliderFlags, (uint)TreeColliderFlags.Solid, Flags.CheckType.MatchAny))
                {
                    SecondaryCollider.isTrigger        = false;
                    SecondaryCollider.gameObject.layer = Globals.LayerNumObstacleTerrain;
                }
                else
                {
                    SecondaryCollider.isTrigger        = true;
                    SecondaryCollider.gameObject.layer = Globals.LayerNumTrigger;
                }
            }
        }