public void OnPlayerEncounter() { if (IsDead) { return; } Motile motile = null; if (worlditem.Is <Motile> (out motile)) { motile.StartMotileActions(); } }
public void OnGainPlayerFocus() { Motile motile = null; if (worlditem.Is <Motile> (out motile)) { motile.StartMotileActions(); } if (State.BroadcastFocus) { Player.Get.AvatarActions.ReceiveAction(AvatarAction.NpcFocus, WorldClock.AdjustedRealTime); } enabled = true; }
public void OnInactive() { if (IsDead) { return; } Motile motile = null; if (worlditem.Is <Motile> (out motile)) { motile.StartMotileActions(); } }
public void OnAddedToGroup() { CurrentThought.OnFleeFromIt += FleeFromThing; CurrentThought.OnKillIt += AttackThing; CurrentThought.OnEatIt += WatchThing; //TODO fix this CurrentThought.OnFollowIt += FollowThing; CurrentThought.OnWatchIt += WatchThing; Motile motile = null; if (worlditem.Is <Motile> (out motile)) { motile.StartMotileActions(); } Characters.Get.BodyTexturesAndMaterials(this, Ghost); }
public void OnAddedToGroup() { //save so the creature den spawner won't get confused //WorldItems.Get.Save(worlditem, true); //initialize the body parts //Body.Initialize (worlditem); //add the body's renderers to worlditem renderers //so they're disabled when appropriate //worlditem.Renderers.AddRange (Body.Renderers); if (Den == null) { IStackOwner owner = null; if (worlditem.Group.HasOwner(out owner)) { Den = (ICreatureDen)owner.worlditem.GetComponent(typeof(ICreatureDen)); //else - we don't have a den so we'll set default roaming distance from props } } if (Den != null) { Den.AddCreature(this.worlditem); } //set up the collective thought object CurrentThought.OnFleeFromIt += FleeFromThing; CurrentThought.OnKillIt += AttackThing; CurrentThought.OnEatIt += EatThing; CurrentThought.OnFollowIt += FollowThing; CurrentThought.OnWatchIt += WatchThing; //CurrentThought.OnMateWithIt += MateWithThing; Motile motile = null; if (worlditem.Is <Motile> (out motile)) { //create motile behaviors //TODO create more logical behaviors for creatures without a den mFollowAction = new MotileAction(); mFollowAction.Name = "Follow action by Creature"; mFollowAction.Type = MotileActionType.FollowTargetHolder; mFollowAction.FollowType = MotileFollowType.Follower; mFollowAction.Expiration = MotileExpiration.TargetOutOfRange; mFollowAction.OutOfRange = Den.Radius; mFollowAction.Range = Den.Radius; //mFollowAction.TerritoryType = MotileTerritoryType.Den; mFollowAction.TerritoryBase = Den; mEatAction = new MotileAction(); mEatAction.Name = "Eat action by Creature"; mEatAction.Type = MotileActionType.FollowGoal; mEatAction.Expiration = MotileExpiration.TargetInRange; mEatAction.Range = Template.MotileTemplate.MotileProps.RVORadius * 2; //mEatAction.TerritoryType = MotileTerritoryType.Den; mEatAction.TerritoryBase = Den; mReturnToDenAction = new MotileAction(); mReturnToDenAction.Name = "Return to Den action by Creature"; mReturnToDenAction.Type = MotileActionType.FollowGoal; mReturnToDenAction.Expiration = MotileExpiration.TargetInRange; mReturnToDenAction.Range = Template.MotileTemplate.MotileProps.RVORadius; mReturnToDenAction.LiveTarget = Den.IOI; //mReturnToDenAction.TerritoryType = MotileTerritoryType.Den; mReturnToDenAction.TerritoryBase = Den; mFleeThreatAction = new MotileAction(); mFleeThreatAction.Name = "Flee threat action by Creature"; mFleeThreatAction.Type = MotileActionType.FleeGoal; mFleeThreatAction.Expiration = MotileExpiration.TargetOutOfRange; mFleeThreatAction.YieldBehavior = MotileYieldBehavior.DoNotYield; mFleeThreatAction.OutOfRange = Den.Radius; mFleeThreatAction.Range = Looker.AwarenessDistanceTypeToVisibleDistance(Template.LookerTemplate.AwarenessDistance); //mFleeThreatAction.TerritoryType = MotileTerritoryType.Den; mFleeThreatAction.TerritoryBase = Den; mPursueGoalAction = new MotileAction(); mPursueGoalAction.Name = "Pursue goal action by Creature"; mPursueGoalAction.Type = MotileActionType.FollowGoal; mPursueGoalAction.Expiration = MotileExpiration.TargetInRange; mPursueGoalAction.YieldBehavior = MotileYieldBehavior.YieldAndWait; mPursueGoalAction.Range = Template.MotileTemplate.MotileProps.RVORadius; //mPursueGoalAction.TerritoryType = MotileTerritoryType.Den; mPursueGoalAction.TerritoryBase = Den; mFocusAction = new MotileAction(); mFocusAction.Name = "Focus action by Creature"; mFocusAction.Type = MotileActionType.FocusOnTarget; mFocusAction.Expiration = MotileExpiration.Duration; mFocusAction.RTDuration = ShortTermMemoryToRT(Template.Props.ShortTermMemory); mFocusAction.YieldBehavior = MotileYieldBehavior.YieldAndFinish; //mFocusAction.TerritoryType = MotileTerritoryType.Den; mFocusAction.TerritoryBase = Den; mWanderAction = motile.BaseAction; mWanderAction.Name = "Base Action (wander) Set By Creature"; mWanderAction.Type = MotileActionType.WanderIdly; mWanderAction.LiveTarget = Den.IOI; //mWanderAction.TerritoryType = MotileTerritoryType.Den; mWanderAction.TerritoryBase = Den; mWanderAction.Range = Den.Radius; mWanderAction.OutOfRange = Den.Radius; if (!IsDead) { motile.StartMotileActions(); } } if (IsDead) { motile.IsRagdoll = true; Body.SetRagdoll(true, 0.1f); Body.transform.position = worlditem.transform.position + Vector3.up; Body.transform.Rotate(UnityEngine.Random.Range(0f, 360f), UnityEngine.Random.Range(0f, 360f), UnityEngine.Random.Range(0f, 360f)); OnDie(); } else { RefreshBehavior(); } }