GNPC: Difference between revisions
Jump to navigation
Jump to search
Rhosyn Celyn (talk | contribs) Created page with "= GPhys.Abstracts.GNPC = '''GPhys.Abstracts.GNPC''' is an abstract base class for generic NPCs in GPhys, providing health, ground checking, thinking logic, and coroutine management. It is designed to be inherited by specific NPC types and supports features like mind control, ragdoll creation, and skin management. == Accessible Variables == ; maxHealth : Maximum health value for the NPC (float). ; groundLayer : Layer mask used for ground detection (LayerMask). ; ground..." |
Rhosyn Celyn (talk | contribs) No edit summary |
||
| Line 2: | Line 2: | ||
'''GPhys.Abstracts.GNPC''' is an abstract base class for generic NPCs in GPhys, providing health, ground checking, thinking logic, and coroutine management. It is designed to be inherited by specific NPC types and supports features like mind control, ragdoll creation, and skin management. | '''GPhys.Abstracts.GNPC''' is an abstract base class for generic NPCs in GPhys, providing health, ground checking, thinking logic, and coroutine management. It is designed to be inherited by specific NPC types and supports features like mind control, ragdoll creation, and skin management. | ||
== Class Hierarchy == | |||
* [[UnityEngine.MonoBehaviour]] | |||
** '''GPhys.Abstracts.GNPC''' (abstract) | |||
*** (Inherit from this class to create custom NPCs) | |||
== Accessible Variables == | == Accessible Variables == | ||
Latest revision as of 01:34, 29 April 2026
GPhys.Abstracts.GNPC
GPhys.Abstracts.GNPC is an abstract base class for generic NPCs in GPhys, providing health, ground checking, thinking logic, and coroutine management. It is designed to be inherited by specific NPC types and supports features like mind control, ragdoll creation, and skin management.
Class Hierarchy
- UnityEngine.MonoBehaviour
- GPhys.Abstracts.GNPC (abstract)
- (Inherit from this class to create custom NPCs)
- GPhys.Abstracts.GNPC (abstract)
Accessible Variables
- maxHealth
- Maximum health value for the NPC (float).
- groundLayer
- Layer mask used for ground detection (LayerMask).
- groundCheckDistance
- Distance to check for ground beneath the NPC (float).
- groundCheckPoint
- Transform used as the origin for ground checking (Transform).
- OnDeath
- Event invoked when the NPC dies (System.Action<GNPC>).
- mindControl
- Enables or disables mind control for the NPC (bool).
- NpcClass
- Abstract string property representing the NPC's class/type.
- CustomRagdollManag
- Action invoked for custom ragdoll management (System.Action<GameObject>).
- isMachineryOrPowerful
- Indicates if the NPC is machinery or powerful (bool).
- RagdollCounterpart
- Prefab for the NPC's ragdoll (GameObject).
- BakedMeshCache
- Array of cached meshes for the NPC (Mesh[]).
- globalDisableThinking
- Disables thinking for all NPCs globally (static bool).
- disableThinking
- Disables thinking for this NPC (bool).
- gnpcNpcClass
- Dictionary mapping types to NPC class names (Dictionary<Type, string>).
- skinnedMeshRenderers
- Array of skinned mesh renderers for the NPC (SkinnedMeshRenderer[]).
- canThink
- Returns true if the NPC is allowed to think (bool, getter).
- destroyRagdoll
- If true, destroys the NPC's colliders when ragdolling (bool).
- isBeingMindControlled
- Returns true if the NPC is being mind controlled (bool, getter).
- CurrentHealth
- Current health value (float, getter).
- IsDead
- Returns true if the NPC is dead (bool, getter).
- IsGrounded
- Returns true if the NPC is on the ground (bool, getter).
- IsDangerous
- Returns true if the NPC is dangerous (bool, getter).
- IsCombine
- Returns true if the NPC is a Combine type (bool, getter).
- Ragdoll
- Returns the ragdoll counterpart GameObject (GameObject, getter).
- GlobalGorillaTransform
- Static transform reference (static Transform).
Accessible Functions
- ScheduleTaskPublic(System.Action task)
- Schedules a task to be executed on the next think.
- ScheduleTaskPublic(System.Action task, float delay)
- Schedules a task to be executed after a delay.
- TakeDamage(float damage)
- Applies damage to the NPC.
- TakeDamage(float damage, GTHealth.DamageType type)
- Applies typed damage to the NPC.
- TakeDamage(float damage, GTHealth.DamageType type, Vector3 hitPoint, Vector3 normalHit)
- Applies typed damage at a specific point.
- SetHealth(float health)
- Sets the NPC's health to a specific value.
- Heal(float amount)
- Heals the NPC by a specified amount.
- GetHealthPercentage()
- Returns the current health as a percentage of maxHealth.
- CanTakeDamageOfType(GTHealth.DamageType type)
- Returns true if the NPC can take the specified damage type.
- ForceKill()
- Instantly kills the NPC.
- MakeNotKillable()
- Makes the NPC invulnerable.
- isNPCTypeThis(string npcType)
- Checks if the NPC matches a given type.
- Gib()
- Destroys the NPC with a blood/gib effect.
- CreateMindControlCamera()
- Creates a camera for mind control.
- DestroyMindControlCamera()
- Destroys the mind control camera.
- GetTargetScore(Collider target)
- Returns a score for a potential target.
- CalculateTargetCameraPosition()
- Calculates the mind control camera's position.
- UpdateMindControlCameraPosition()
- Updates the mind control camera's position.
- WorldSpaceCenter()
- Returns the NPC's center in world space.
- EyePosition()
- Returns the NPC's eye position.
- HandleMindControlCameraInput()
- Handles input for mind control camera.
- FixedUpdate()
- Unity physics update method.
- ForceChangeState(string newState)
- Forces the NPC to change state.
- AddSkin(INPCSkin skin)
- Adds a skin to the NPC.
- ApplySkin(INPCSkin skin)
- Applies a skin to the NPC.
- GetCurrentSkin()
- Returns the currently applied skin.
- GetAvailableSkins()
- Returns all available skins.
- CreateRagdoll(Vector3 velocity, Transform parent = null)
- Creates a ragdoll for the NPC.
- TryFindTorsoOrPelvisFromRagdoll(Transform root)
- Finds the torso or pelvis transform in a ragdoll.
- TryFindTorsoOrPelvisFromRagdoll_RB(Transform root)
- Finds the torso or pelvis rigidbody in a ragdoll.
- SkewerNPC(Transform skewerFoot)
- Skewers the NPC and creates a ragdoll.
- ReleaseSkewer(Vector3 velocity)
- Releases the NPC from a skewer with velocity.
Abstract Methods (must be implemented by derived classes)
- Think()
- Called periodically by the thinking system.
- OnDie()
- Called when the NPC dies.
- HandleStateChange()
- Handles state changes for the NPC.
- GetCurrentState()
- Returns the current state as a string.
- HandleForceChangeState(string newState)
- Handles forced state changes.
Nested Types
- NPCTypeSafety
- Enum for NPC safety type (Friendly, Hostile, Neutral).
- INPCSkin
- Interface for NPC skins (Name, ApplyTo, RemoveFrom).
---
This page documents the core features and API of the GNPC base class in GPhys.