| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /******************************************************************************
- *
- * FILE
- * Group.cpp
- *
- * DESCRIPTION
- * Group manager for GameObjects
- *
- * PROGRAMMER
- * Denzil E. Long, Jr.
- *
- * VERSION INFO
- * $Author: Denzil_l $
- * $Revision: 1 $
- * $Modtime: 4/17/00 9:47a $
- * $Archive: /Commando/Code/Scripts/Group.cpp $
- *
- ******************************************************************************/
- #include "group.h"
- /******************************************************************************
- *
- * NAME
- * Group::Group
- *
- * DESCRIPTION
- * Group Constructor
- *
- * INPUTS
- * Name - Name of team.
- *
- * RESULTS
- * NONE
- *
- ******************************************************************************/
- Group::Group(const char* name)
- {
- mName[0] = '\0';
- // Make copy of team name
- assert(name != NULL);
- if (name != NULL)
- {
- strncpy(mName, name, sizeof(mName));
- mName[sizeof(mName) - 1] = '\0';
- }
- }
- /******************************************************************************
- *
- * NAME
- * Group::~Group
- *
- * DESCRIPTION
- * Group Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULTS
- * NONE
- *
- ******************************************************************************/
- Group::~Group()
- {
- }
- /******************************************************************************
- *
- * NAME
- * Group::GetName
- *
- * DESCRIPTION
- * Retrieve name of Group.
- *
- * INPUTS
- * NONE
- *
- * RESULTS
- * Name - Name of team
- *
- ******************************************************************************/
- const char* Group::GetName(void) const
- {
- return mName;
- }
- /******************************************************************************
- *
- * NAME
- * Group::AddMember
- *
- * DESCRIPTION
- * Add a game object to the Group.
- *
- * INPUTS
- * GameObject - Pointer to game object to add.
- *
- * RESULTS
- * NONE
- *
- ******************************************************************************/
- void Group::AddMember(GameObject* object)
- {
- assert(object != NULL);
- // Add the object if it is not already a member of the team.
- if (IsMember(object) == false)
- {
- mMembers.Add(object);
- }
- }
- /******************************************************************************
- *
- * NAME
- * Group::RemoveMember
- *
- * DESCRIPTION
- * Remove a game object from the Group.
- *
- * INPUTS
- * GameObject - Pointer to game object to remove.
- *
- * RESULTS
- * NONE
- *
- ******************************************************************************/
- void Group::RemoveMember(GameObject* object)
- {
- assert(object != NULL);
- mMembers.Delete(object);
- }
- /******************************************************************************
- *
- * NAME
- * Group::IsMember
- *
- * DESCRIPTION
- * Check if a game object is member of the Group.
- *
- * INPUTS
- * GameObjectID objectID
- *
- * RESULTS
- * bool
- *
- ******************************************************************************/
- bool Group::IsMember(GameObject* object) const
- {
- assert(object != NULL);
- for (int index = 0; index < mMembers.Count(); index++)
- {
- if (mMembers[index] == object)
- {
- return true;
- }
- }
- return false;
- }
- /******************************************************************************
- *
- * NAME
- * MemberCount
- *
- * DESCRIPTION
- * Get the number of members in the Group.
- *
- * INPUTS
- * NONE
- *
- * RESULTS
- * Count - Member count
- *
- ******************************************************************************/
- int Group::MemberCount(void) const
- {
- return mMembers.Count();
- }
- /******************************************************************************
- *
- * NAME
- * Group::GetMember
- *
- * DESCRIPTION
- * Get a Group member.
- *
- * INPUTS
- * int index
- *
- * RESULTS
- * GameObject*
- *
- ******************************************************************************/
- GameObject* Group::GetMember(int index)
- {
- assert(index >= 0);
- assert(index < MemberCount());
- return mMembers[index];
- }
- /******************************************************************************
- *
- * NAME
- * Group::SendCommand
- *
- * DESCRIPTION
- * Send a command to all the members of the Group.
- *
- * INPUTS
- * Command - Command to send to Group members.
- * Data - Command specific data parameter.
- *
- * RESULTS
- * NONE
- *
- ******************************************************************************/
- void Group::SendCustomEvent(GameObject* from, int event, int data)
- {
- for (int index = 0; index < mMembers.Count(); index++)
- {
- GameObject* object = mMembers[index];
- assert(object != NULL);
- Commands->Send_Custom_Event(from, object, event, data);
- }
- }
|