예제 #1
0
 public NonPlayerCreature(
     Vector3 position,
     float height,
     float radius,
     float mass,
     float sensitivityRadius,
     Controller controller,
     Renderable renderable,
     float visionAngle,
     int listeningSensitivity,
     int sneak,
     int intimidation,
     Part part,
     Spawner spawn
     )
     : base(position, height, radius, mass, renderable, new ListeningSensor(sensitivityRadius, visionAngle, listeningSensitivity), controller, 1)
 {
     mIncapacitated = false;
     Sneak = sneak;
     Intimidation = intimidation;
     Controller = controller;
     AddPart(part, 0);
     Spawner = spawn;
     CharacterController.HorizontalMotionConstraint.Speed = 9.0f;
 }
예제 #2
0
파일: Creature.cs 프로젝트: thormme/Chimera
        /// <summary>
        /// Gets a list of bones to be used to connect a part.
        /// </summary>
        /// <param name="part">The part to fetch bones for.</param>
        /// <returns>List of bones for use by the part.</returns>
        protected List<PartBone> GetPartBonesForPart(Part part)
        {
            List<PartBone> partBones = new List<PartBone>();

            foreach (Part.SubPart subPart in part.SubParts)
            {
                bool foundBone = false;

                // Look for the preferred bones first.
                foreach (PartBone preferredBone in subPart.PreferredBones)
                {
                    if (!foundBone)
                    {
                        if (mUnusedPartBones.Contains(preferredBone) && !partBones.Contains(preferredBone))
                        {
                            partBones.Add(preferredBone);
                            foundBone = true;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                // If too few preferred bones were available choose any free bone.
                foreach (PartBone unusedBone in mUnusedPartBones)
                {
                    if (!foundBone)
                    {
                        if (!partBones.Contains(unusedBone))
                        {
                            partBones.Add(unusedBone);
                            foundBone = true;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return partBones;
        }
예제 #3
0
파일: Creature.cs 프로젝트: thormme/Chimera
        /// <summary>
        /// Remove attached part from the creature.
        /// </summary>
        /// <param name="part"></param>
        public virtual void RemovePart(Part part)
        {
            int slot = -1;
            PartAttachment partAttachment = null;
            for (int i = 0; i < mPartAttachments.Count(); ++i)
            {
                PartAttachment attachment = mPartAttachments[i];
                if (attachment == null)
                {
                    continue;
                }

                if (part == attachment.Part)
                {
                    partAttachment = attachment;
                    slot = i;
                    break;
                }
            }

            if (partAttachment == null)
            {
                throw new Exception("Could not remove part as it is not owned by the creature");
            }

            foreach (PartBone partBone in partAttachment.Bones)
            {
                mUnusedPartBones.Add(partBone);
            }

            mPartAttachments[slot] = null;
            partAttachment.Part.Creature = null;
        }
예제 #4
0
파일: Creature.cs 프로젝트: thormme/Chimera
        /// <summary>
        /// Attach part to the creature.
        /// </summary>
        /// <param name="part">The part to attach.</param>
        /// <param name="slot">The slot in the list to put the part</param>
        public virtual void AddPart(Part part, int slot)
        {
            if (slot >= mPartAttachments.Count())
            {
                return;
            }

            List<PartBone> usedBones = GetPartBonesForPart(part);
            foreach (PartBone partBone in usedBones)
            {
                mUnusedPartBones.Remove(partBone);
            }

            mPartAttachments[slot] = new PartAttachment(part, usedBones);

            part.Creature = this;

            //mPartRotations = new Matrix[mPartAttachments[0].Bones.Count];
            //mBoneUp = new Vector3[mPartAttachments[0].Bones.Count];
            //mBoneForward = new Vector3[mPartAttachments[0].Bones.Count];
            //mBoneRight = new Vector3[mPartAttachments[0].Bones.Count];
            //for (int i = 0; i < PartAttachments[0].Bones.Count; ++i)
            //{
            //    mPartRotations[i] = Matrix.Identity;
            //    mBoneUp[i] = Vector3.Up;
            //    mBoneForward[i] = Vector3.Forward;
            //    mBoneRight[i] = Vector3.Right;
            //}
        }
예제 #5
0
파일: Creature.cs 프로젝트: thormme/Chimera
 public PartAttachment(Part part, List<PartBone> bones)
 {
     Part = part;
     Bones = bones;
 }
예제 #6
0
 public override void RemovePart(Part part)
 {
     base.RemovePart(part);
     Die();
 }